[英]Rebase a branch that has already been merged
I have a feature branch that has already been merged (in M
) but reverted afterwards (in R
): 我有一个已经合并的功能分支(在
M
),但之后又还原了(在R
):
S---o-o-----M-o-R-o
\ /
A-----B-C ^ master
^ feature
I want to rebase the feature
branch onto the current master
so I get: 我想将
feature
分支重新建立到当前的master
所以我得到:
S---o-o-----M-o-R-o-A'-B'-C'
\ /
A-----B-C ^ new master or new branch
^ old master
^ feature
This is similar to the process described in the addendum of revert-a-faulty-merge.txt but instead of basing the new branch on S
I want to base it on the current master
. 这类似于revert-a-faulty-merge.txt 附录中描述的过程,但是我不想将新分支基于
S
而是希望基于当前master
。
According to this question this solution should work: 根据此问题,此解决方案应起作用:
git rebase --onto stable D fix/123
This is still kind of risky because you need to take the SHA of D (and NOT X for instance).这仍然有点冒险,因为您需要采用D的SHA(例如,不是X)。
So I tried git rebase --no-ff --onto master S feature
but it just advanced the feature
label to the master
label and said "Fast-forwarded feature to master" without generating any new commits. 因此,我尝试在
git rebase --no-ff --onto master S feature
但是它只是将feature
标签提升到了master
标签,并说“快速转发功能要掌握”而没有生成任何新的提交。
So how can I basically copy the whole feature
branch on top of master? 那么,基本上我该如何复制整个
feature
分支到master呢?
git cherry-pick
now supports a range of commits, like so: git cherry-pick
现在支持一系列提交,如下所示:
git cherry-pick S..C
This will get the commits after S up through C. You can also specify to start from the parent of A, like so: 这将在 S之后通过C获得提交。您还可以指定从A的父项开始,如下所示:
git cherry-pick A^..C
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.