本文很少讲解Git命令的使用,旨在说明开发团队中如何使用git进行团队协做,release实践,如何进行hotfix等。这里推荐没用使用过Git的朋友参考廖雪峰老师的教程:git
孔子曰:一图顶十言。下图归纳了Git核心的工做流程,开发feature,修改bug,hotfix。app
始终保存的是最近一次上线PROD的代码测试
始终保存的是最新提交的代码网站
feature/<task-number>-short-description
,bug/<task-number>-short-description
上述过程当中,本地git操做使用的部分命令url
git checkout -b feature/<task-number>-short-description git checkout -b bug/<task-number>-short-description git push origin feature/<task-number>-short-description git push origin bug/<task-number>-short-description
建立pull request一般是经过git代码网站进行操做。spa
hotfix/<task-number>-short-description
git clone <url> --branch <branch name> --single-branch [folder]
只clone master分支到当前路径(省略了folder):code
git clone https://xxx.com/common.git --branch master --single-branch
此时使用git branch -r
能够看到远程分支:教程
origin/HEAD -> origin/master origin/master
说明咱们只clone了master分支到本地仓库。图片
当git clone命令执行完成后,origin就存放了远程仓库地址。在命令中使用origin,就指代远程仓库。ip
git branch -vv
经过这种方式建立的本地分支,自动把该远程分支设置为本地分支的upstream,如此一来,git pull
,git push
操做时再也不须要指明远程分支。
git checkout -b <local-branch-name> --track origin/<remote-branch-name>
使用git checkout -b <branch-name>
建立的本地分支,能够显式指定其对应的远程分支。
git branch --set-upstream-to origin/<remote-branch-name>
在push本地分支到远程仓库时,顺便指定本地分支的upstream分支。
git push -u origin <local-branch-name>
branch-name能够省略,默认为当前分支。