[英]How to sync multiple feature branches with master in git
My Scenario is this: From master branch to feature branch1, add changes to branch1 then create another branch from branch1 called branch2, then add changes to branch2.我的场景是这样的:从 master 分支到 feature branch1,将更改添加到 branch1,然后从 branch1 创建另一个名为 branch2 的分支,然后将更改添加到 branch2。
If there are then pending changes to the master branch, what's the best approach to sync all branches with the master branch如果 master 分支有待处理的更改,那么将所有分支与 master 分支同步的最佳方法是什么
Branch creation as follows Master to F1 then F1 to F2
You could rebase branch2
on top of master
using --update-refs
which is a newish option that will also update references that are setup in the path to branch2
, so should move the position of branch1
.您可以使用
--update-refs
将branch2
变基到master
之上,这是一个新选项,它还会更新在branch2
路径中设置的引用,因此应该移动 position 的branch1
。
git checkout branch2
git rebase --update-refs master
The kind of step by step way would be:那种循序渐进的方式是:
git checkout branch1
git branch temp # let's set a temporary marker before I move it
git rebase master
# now time to rebase branch2
git rebase --onto branch1 temp branch2
# remove the temporary branch if things went fine
git branch -D temp
The last rebase will rebase commits in the temp..branch2
range on top of branch1
最后一个变基将变基
temp..branch2
范围内的提交在 branch1 branch1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.