我有一个带有两个分支的仓库,main并且feature. 的输出git log --graph --format='%s %d' --all如下所示:
* e (main)
| * d (HEAD -> feature)
| * Merge branch 'main' into feature
| |\
| |/
|/|
* | c
| * b
|/
* a
我现在想将e我的分支上的提交包含在main分支上的合并提交中feature,以便我有最新的更改,但如果分支上的main提交已经被推送,则不必强制推送。我也不想在我的历史记录中有另一个合并提交。我希望我的最终图表如下所示:bfeature
| * d (HEAD -> feature)
| * Merge branch 'main' into feature
| |\
| |/
|/|
* | e (main)
* | c
| * b
|/
* a
我可以通过git rebase -i main --onto :/a --rebase-merges将交互式变基的说明更改为:
label onto
reset 9870d06 # a
pick 579c27a b
merge -C d4caa73 main # Merge branch 'main' into feature
pick f672b7f d
但问题在于,在之前的合并提交中,我必须解决 and 之间的冲突b,c而使用这种方法,我将不得不再次解决这个冲突。因此,我真正想做的是拿起我在提交时中断的合并提交,然后c继续main合并e到feature. b有没有办法做到这一点?也许还有一种方法可以暂时引入另一个合并提交,然后再压缩这两个合并提交?