我有两个分支
branch_a-> -x-x-x-x-x-A-C-D-E
(<-ACDE是branch_a上的最新提交)
branch_b-> -x-x-x-x-x-B(A-amended)
(<-B是A的修订版本的提交,与A相比,更改不多)
我想要
branch_a -> -x-x-x-x-A-C-D-E
\ ->(TARGET_branch=) -x-x-x-x-x-B-C-D-E ( I know that as B is changed commit id of C,D,E may also change and they will become (e.g.) F-G-H , that is accepted just dont wanna lose the individuality of the commit.
branch_b ->-x-x-x-x-x-B-
所有这些都应在没有任何合并提交且没有丢失任何提交的情况下完成
对我来说,一种可能的解决方案是取B和A的差异,转到branch_a并执行git rebase -i HEAD~4
,用对B的更改来修改提交A,然后继续进行变基。
现在,这是一种非常粗糙的方法。
好了,我们将不得不在某个地方解决合并冲突,但是可以肯定可以使它简单得多。有人知道更简单的方法吗?
那将是一个rebase --onto
,以便仅选择所需的提交。
这将更改分支B,然后可以将A重置为B:
git switch branch_b
git rebase --onto B A branch_a
仅C,D,E将基于B进行重新定位。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句