如何在开发分支上重新设置功能分支
How to rebase feature branch on dev branch
我有这个
a -- b -- c -- f <-- dev
\
d -- e -- g <-- feature
我想要这个
a -- b -- c -- f -- d -- e -- g <-- dev
我知道这与 rebase 命令有关。但是,当我键入 git rebase dev feature
时,提交会转到功能分支并且 dev 不会更新。如果我使用 git rebase feature dev
那么最后一次提交是来自 master 的提交,并且我有重复的提交。我怎样才能做到这一点?
假设我希望 feature
保持在原处而不移动它(如最终图表所示),我会这样做:
git checkout dev
git cherry-pick dev..feature
就是这样
如果之后要删除功能分支:
git branch -D feature
一般来说,更清洁的方法(但步骤更多)是:
git checkout feature
git rebase dev
git checkout dev
git merge feature # (this fill fast-forward to the tip of feature)
git branch -d feature # no need to use -D this time
我有这个
a -- b -- c -- f <-- dev
\
d -- e -- g <-- feature
我想要这个
a -- b -- c -- f -- d -- e -- g <-- dev
我知道这与 rebase 命令有关。但是,当我键入 git rebase dev feature
时,提交会转到功能分支并且 dev 不会更新。如果我使用 git rebase feature dev
那么最后一次提交是来自 master 的提交,并且我有重复的提交。我怎样才能做到这一点?
假设我希望 feature
保持在原处而不移动它(如最终图表所示),我会这样做:
git checkout dev
git cherry-pick dev..feature
就是这样
如果之后要删除功能分支:
git branch -D feature
一般来说,更清洁的方法(但步骤更多)是:
git checkout feature
git rebase dev
git checkout dev
git merge feature # (this fill fast-forward to the tip of feature)
git branch -d feature # no need to use -D this time