git show <MERGE_COMMIT>
将会显示出合并提交所做的解决方案(如果有的话)。git log -p -c
或git log -p --cc
。来自git log的手册页面。 -c
With this option, diff output for a merge commit shows the differences from each
of the parents to the merge result simultaneously instead of showing pairwise
diff between a parent and the result one at a time. Furthermore, it lists only
files which were modified from all parents.
--cc
This flag implies the -c option and further compresses the patch output by
omitting uninteresting hunks whose contents in the parents have only two
variants and the merge result picks one of them without modification.
更近期的选择(2022年,九年后)是:
git log --remerge-diff
在 Git 2.36 (2022 年第二季度) 中, "git log --remerge-diff
"(man) 显示机械合并结果和实际记录在合并提交中的结果之间的差异。
请参考以下提交记录:commit 0dec322, commit 0d83d82, commit 20323d1, commit 95433ee, commit 6054d1a, commit a28d094, commit 24dbdab, commit 35f6967, commit 7b90ab4, commit db757e8 (2022年2月2日) 由Elijah Newren (newren
)提交。
请参考以下提交记录:commit 5046831 (2021年12月21日) 由Junio C Hamano (gitster
)提交。
(合并自Junio C Hamano -- gitster
--在commit 90b7153,2022年2月16日)
show, log
: 提供 --remerge-diff 功能署名:Elijah Newren
当使用此选项时,我们会重新合并所有 (两个父节点的) 合并提交,并将实际的合并提交与自动创建的版本进行差异比较,以展示用户如何:
- 删除冲突标记,
- 解决不同的冲突版本,以及
- 可能在解决语义合并问题时添加新的更改**(或者可能只是为了隐藏其他随机更改)。
此功能通过创建一个临时对象目录并将其标记为主要对象存储来实现。
这样一来,在自动合并过程中创建的任何 blob 或 tree 都可以通过仅删除临时对象目录中的所有对象来轻松移除。此实现存在一些次优点:
log --remerge-diff
变得很慢,因为在运行时,临时对象目录可能会填满许多松散的对象。- 日志输出可能会混淆 "warning: cannot merge binary files" 消息的位置,因为
ll-merge.c
在运行时无条件将这些消息写入 stderr 而不允许调用方管理它们。- 重要的冲突和警告消息被简单地丢弃;因此,对于像修改/删除、重命名/重命名或文件/目录这样不能用内容冲突标记表示的冲突,
--remerge-diff
的用户可能无法知道已经存在一个已解决的冲突(并且这可能激发了合并提交中的其他更改)。- 在解决上述问题时,需要注意有些不重要的冲突和警告消息可能开始被包含。
相反,我们应该确保这些消息仍然被丢弃。
后续的提交将解决这些问题。
diff-options
现在在其man page中包括:
--diff-merges=(off|none|on|first-parent|1|separate|m|combined|c|dense-combined|cc|remerge|r)
diff-options
现在在其手册页面中包括以下内容:
--diff-merges=remerge:
--diff-merges=r:
--remerge-diff:
使用此选项,两个父合并提交将重新合并以创建一个临时树对象 - 可能包含有冲突标记等文件。
然后显示该临时树与实际合并提交之间的差异。
当使用此选项时发出的输出可能会更改,它与其他选项的交互也可能会更改(除非有明确的文档)。
请注意,上面的提交之一在Git 2.36(2022年第二季度)中有所撤销:
请参见提交624a935(由Elijah Newren (newren
)于2022年3月2日提交)。
(由Junio C Hamano -- gitster
--合并于提交8b44e05, 2022年3月13日)
merge-ort
:默认情况下排除内部合并的消息签署者:Elijah Newren
当设置
GIT_MERGE_VERBOSITY
为5时,merge-recursive仅会报告来自内部合并的信息。现在对于merge-ort
也做同样的处理。请注意,基于以下两个事实,0d83d82("
merge-ort
: 标记内部合并的冲突/警告信息可以省略",2022-02-02,Git v2.36.0 -- merge列在batch #4中)有所回退:
git log --remerge-diff 111^!
开始:这是一个限制在111上的日志,它应该显示出机械合并结果与实际记录在合并提交(111)中的结果之间的差异。 - VonC
git log --remerge-diff
命令将会展示你在合并冲突解决中所做的工作!请参见下面的回答。 - VonC