Git global setup
git config --global user.name "用户名" git config --global user.email "邮箱" git config --global credential.helper store # 设置不用每次push/pull都输入账号密码
Create a new repository
git clone http://gitlab.xxx.com/xxx/abc.git cd abc touch README.md git add README.md git commit -m "add README" git push -u origin master
Existing folder or Git repository
cd existing_folder git init git remote add origin http://gitlab.xxx.com/xxx/abc.git git add . git commit git push -u origin master
Update
git status git add . git commit -m "modified" git pull origin master git push -u origin master 关于撤销commit: git reset HEAD^ # 不删除工作空间改动代码,撤销commit,并且撤销git add . git reset --soft HEAD^ # 不删除工作空间改动代码,撤销commit,不撤销git add . git reset --hard HEAD^ # 删除工作空间改动代码,撤销commit,撤销git add . 如果commit注释写错了,只是想改一下注释: git commit --amend # 进入默认vim编辑器,修改注释完毕后保存就好了