git checkout dev
git checkout -b feature-s16
git add xxx
git commit xxx
# 多人协作在同一个feature分支上进行开发时,使用rebase合并远程分支
git checkout feature-s16
git fetch origin
git rebase origin/feature-s16
git push origin feature-s16
# 本地dev分支先跟远程dev同步一下
git checkout dev
git fetch origin
git rebase origin/dev
# 再把feature分支合并到dev分支,使用--no-ff强制生成merge commit
git merge --no-ff feature-s16
git push origin dev
# 一段时间后删除feature分支,包括本地分支和远程分支
git branch -d feature-s16
git push origin --delete feature-s16
git checkout dev
git fetch origin
git rebase origin/dev
git checkout -b release-s16
# 在release分支上测试,修改bug
# 更新本地master分支
git checkout master
git fetch origin
git rebase origin/master
# 合并release分支
git merge --no-ff release-s16
git push origin master
# 打上相应的tag,并编写相应的Release Notes
git tag -a v1.0.4 -m "2015-09-26 released"
git push origin v1.0.4
# 把release分支合并回dev分支
git checkout dev
git fetch origin
git rebase origin/dev
git merge --no-ff release-s16
# 一段时间后删除release分支,包括本地分支和远程分支
git branch -d release-s16
git push origin --delete release-s16
git checkout master
git fetch origin
git rebase origin/master
git checkout -b hotfix-v1.0.4.1
# 在hotfix分支上开发,测试,修改bug
# 更新本地master分支
git checkout master
git fetch origin
git rebase origin/master
# 合并hotfix分支
git merge --no-ff hotfix-v1.0.4.1
git push origin master
# 打上相应的tag,并编写相应的Release Notes
git tag -a v1.0.4.1 -m "hot fix for xxx"
git push origin v1.0.4.1
# 把hotfix分支合并回dev分支或release分支
git checkout dev
git fetch origin
git rebase origin/dev
git merge --no-ff hotfix-v1.0.4.1
# 一段时间后删除hotfix分支,包括本地分支和远程分支
git branch -d hotfix-v1.0.4.1
git push origin --delete hotfix-v1.0.4.1
- feature分支之间有代码依赖,应该用merge --no-ff
# 假设feature-2需要feature-1的代码
git checkout feature-2
git merge feature-1