GitFlow 实践
1. 创建远程Git仓库
Create: http://../GitFlowRemote.git
2. 创建本地仓库、关联远程仓库
-
创建
$ git init
-
关联
git remote add [<options>] <name> <url>
$ git remote add origin http://github.com/.../GitFlowRemote.git
git pull <remote> <branch> --allow-unrelated-histories
$ git pull origin master --allow-unrelated-histories
$ git push origin master
3. 创建Develop分支
$ git branch develop
$ git push -u origin develop
4. 开始新的Feature
$ git checkout -b NewFeature develop
$ git push -u origin NewFeature
循环下面3个步骤,直到完成Feature
$ git add .
$ git commit -m “NewFeature”
$ git push origin NewFeature
5. 完成Feature
$ git pull origin develop
$ git checkout develop
$ git merge --no-ff NewFeature
$ git push origin develop
$ git branch -d NewFeature
$ git push origin --delete NewFeature
6. 功能完成之后,开始一个Release
$ git checkout -b release-0.1.0 develope
7. 完成一个Release
将release-0.1.0分支合并到master
$ git checkout master
$ git merge --no-ff release-0.1.0
$ git push
将release-0.1.0分支合并到develop
$ git checkout develop
$ git merge --no-ff release-0.1.0
$ git push
删除本地release-0.1.0分支
$ git branch -d release-0.1.0
删除远程release-0.1.0分支
$ git push origin --delete release-0.1.0
最后,为该Release创建一个Tag
$ git tag -a v0.1.0 master
$ git push --tags
8. v0.1.0 发现Bug并修复
$ git checkout -b fix-0.1.1 master
修复编码… commit.
将fix-0.1.1合并到master分支
$ git checkout master
$ git merge --no-ff fix-0.1.1
$ git push
将fix-0.1.1合并到develop分支
$ git checkout develop
$ git merge --no-ff fix-0.1.1
$ git push
$ git branch -d fix-0.1.1
最后,为该bug修复创建一个Tag
$ git tag -a v0.1.1 master
$ git push --tags
参考博客
by @wxsmile