https://www.jianshu.com/p/41910dc6ef29
The concept of Git Flow
In using Git commit process if there is no clear process and planning, otherwise, everyone filed a bunch of disorganized, the project will become difficult to coordinate and maintain quickly.
Git version management also needs a clear process and norms.
Vincent Driessen To solve this problem presents A Successful Branching Model Git
Git Flow The following flow chart is presented based on Vincent Driessen
Git Flow common branch
-
Production branch
That is, we often use the Master branch, the branch recently released the code to the production environment, recently released Release, this branch can only merge from other branches, can not be modified directly in this branch
-
Develop branch
This branch is our is our main development branch, contains all the code you want to publish to the next Release, the main merged with other branches, such as branches Feature
-
Feature branch
This branch is mainly used to develop a new feature, once the development is completed, we merged back into Develop branch into the next Release
-
Release branches
When you need a new Release of a release, we create a Release branch-based Develop branch, after the completion of Release, we incorporated into the Master and Develop branch
-
Hotfix branch
When we found Production of new Bug, we need to create a Hotfix, after the completion of Hotfix, we merged back into Master and Develop branch, so Hotfix changes will enter next Release
How to use Git Flow
-
Master / Devlop branch
Commit in all branches should be marked on the Master Tag, Master Commit does not exist under normal circumstances, Devlop branch created based on the Master branch
-
Feature branch
Feature分支做完后,必须合并回Develop分支, 合并完分支后一般会删点这个Feature分支,毕竟保留下来意义也不大。
-
Release 分支
Release分支基于Develop分支创建,打完Release分支之后,我们可以在这个Release分支上测试,修改Bug等。同时,其它开发人员可以基于Develop分支新建Feature (记住:一旦打了Release分支之后不要从Develop分支上合并新的改动到Release分支)发布Release分支时,合并Release到Master和Develop, 同时在Master分支上打个Tag记住Release版本号,然后可以删除Release分支了。
-
Hotfix 分支
hotfix分支基于Master分支创建,开发完后需要合并回Master和Develop分支,同时在Master上打一个tag。
Git Flow 命令示例
创建 Devlop
git branch develop
git push -u origin develop
开始 Feature
# 通过develop新建feaeure分支
git checkout -b feature develop
# 或者, 推送至远程服务器:
git push -u origin feature
# 修改md文件 git status git add . git commit
完成 Feature
git pull origin develop
git checkout develop
#--no-ff:不使用fast-forward方式合并,保留分支的commit历史
#--squash:使用squash方式合并,把多次分支commit历史压缩为一次
git merge --no-ff feature
git push origin develop
git branch -d some-feature
# 如果需要删除远程feature分支:
git push origin --delete feature
开始 Release
git checkout -b release-0.1.0 develop
完成 Release
git checkout master
git merge --no-ff release-0.1.0
git push
git checkout develop
git merge --no-ff release-0.1.0
git push
git branch -d release-0.1.0
git push origin --delete release-0.1.0
# 合并master/devlop分支之后,打上tag
git tag -a v0.1.0 master
git push --tags
开始 Hotfix
git checkout -b hotfix-0.1.1 master
完成 Hotfix
git checkout master
git merge --no-ff hotfix-0.1.1
git push
git checkout develop
git merge --no-ff hotfix-0.1.1
git push
git branch -d hotfix-0.1.1
git push origin --delete hotfix-0.1.1
git tag -a v0.1.1 master
git push --tags
使用建议
如果你的代码没有清晰流程和规划,那么强烈推荐使用Vincent Driessen 提出的GIt flow
让你的代码管理骚起来。
结尾
本站文章图片等等来源于网络,仅作为学习之用,版权归原作者所有.如果侵犯了您的权益,请来信告知,我会尽快删除.