手动修改合并提交的示例

Examples of manual amendments to merge commits

git rebase --preserve-merges

文档说 "Merge conflict resolutions or manual amendments to merge commits are not preserved"。

我了解如何使用 rerere 来处理合并冲突,但合并提交的手动修改到底是什么? rerere 也处理这个问题吗?如果没有,是否有解决方法?

The doc says that "Merge conflict resolutions or manual amendments to merge commits are not preserved".

这句话说的(不太好)是--preserve-mergesgit rebase实际上重新合并。

一般情况下不可能保留原来的合并,Git干脆不去尝试。相反,它指出原始提交 M 是与额外父项 p2p3 的合并, ..., pN 在您要变基的链中的父项之上。因此,当复制 M 时,它不会执行 git cherry-pick <ID>,而是 git 合并 <em>p2</em> 。 ..。当然,这会产生全新的合并。

rebase 代码根本不会调整您的 rerere 设置,因此您可以得到您设置的任何内容。

... what exactly are manual amendments to merge commits?

这可能是最好的例子:

$ git checkout br1
$ git merge --no-commit br2
Automatic merge went well; stopped before committing as requested
$ git status --short
A  file2
$ echo 'sneaky sneaky' >> file2
$ git add file2
$ git commit --no-edit
[br1 86ea409] Merge commit 'br2' into br1

我添加到 file2 的行在任何一个分支中都没有出现:我手动修改了它。

(等效地,我可以让合并执行自动提交,然后使用 git commit --amend,这会将原始合并推到一边并使用我拥有的任何东西放置新的合并 git add从那时起就进入了索引。)