git工作流:git flow

2018-07-30  本文已影响0人  我真的是昵称啊
gitFlow.png

Git Flow常用的分支

  1. Production 分支
    也就是我们经常使用的Master分支,这个分支最近发布到生产环境的代码,最近发布的Release, 这个分支只能从其他分支合并,不能在这个分支直接修改
  2. Develop 分支
    这个分支是我们是我们的主开发分支,包含所有要发布到下一个Release的代码,这个主要合并与其他分支,比如Feature分支
  3. Feature 分支
    这个分支主要是用来开发一个新的功能,一旦开发完成,我们合并回Develop分支进入下一个Release
  4. Release分支
    当你需要一个发布一个新Release的时候,我们基于Develop分支创建一个Release分支,完成Release后,我们合并到Master和Develop分支
  5. Hotfix分支
    当我们在Production发现新的Bug时候,我们需要创建一个Hotfix, 完成Hotfix后,我们合并回Master和Develop分支,所以Hotfix的改动会进入下一个Release

Git Flow代码示例

a. 创建develop分支

git branch develop
git push -u origin develop 

b. 开始新Feature开发

git checkout -b some-feature develop
# Optionally, push branch to origin:
git push -u origin some-feature    

做一些改动

git status
git add some-file
git commit    

c. 完成Feature 一般提交merge request~~

git pull origin develop
git checkout develop
git merge --no-ff some-feature
git push origin develop

git branch -d some-feature

If you pushed branch to origin:

git push origin --delete some-feature    

d. 开始Relase

git checkout -b release-0.1.0 develop

e. 完成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

If you pushed branch to origin:

git push origin --delete release-0.1.0   

git tag -a v0.1.0 master
git push --tags

f. 开始Hotfix

git checkout -b hotfix-0.1.1 master    

g. 完成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 tag -a v0.1.1 master
git push --tags
上一篇 下一篇

猜你喜欢

热点阅读