git配置全局的用户名和邮箱
查看用户名和邮箱
1 2
| git config user.name git config user.email
|
记住密码
在服务器上 clone 代码第一次通常会提示输入密码,为了下次不再提示,可以在 clone 后做如下操作
1
| git config credential.helper store
|
初始化项目
1 2 3 4 5 6 7 8
| cd project_root git init git add . git commit -m 'init commit' git remote add origin ${repository_path} git pull origin master # 同步代码 git push origin master # push代码到远程仓库 git clone ${repository_path}
|
重新提交
提交后如果发现遗漏可以使用 git commit –amend 重新提交
1 2 3
| git commit -m 'initial commit' git add forgotten_file git commit
|
撤销提交文件
1 2 3 4 5 6 7 8
| git checkout -- <file> git reset HEAD <file>... git reset HEAD^ git reset HEAD^ a.py git reset –soft HEAD~3 git reset –hard origin/master git reset 057d git revert HEAD
|
原文链接: http://yoursite.com/2018/10/31/git的初始用/
版权声明: 转载请注明出处.