准备:查看分支情况
# 查看远程仓库所有分支
$ git branch -r
origin/master
# 查看本地仓库所有分支
$ git branch -a
* master
remotes/origin/master
第一步:切换到要提交代码的分支,比如master分支
$ git checkout master
第二步:将服务器代码同步到本地,使两边代码一致,不至于正式提交时发生冲突
$ git pull
Already up to date.
第三步:查看当前状态,确认有哪些新的代码文件要提交的
$ git status
第四步:将需要提交的代码从本地仓库的工作区目录压缩后添加到暂存区:.git\objects
$ git add /path-to-file/file-name
第五步:提交代码
$ git commit -m "提交xxx改动"
$ git status
第六步:将本地仓库的分支代码推送到远程仓库的分支
$ git push origin master
第七步:拉取远程仓库代码,保证代码同步
$ git pull
Already up to date.
# 完成 !