给定合并提交 SHA1,您如何查看/显示已完成的 git 合并冲突解决方案?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15277708/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you see / show a git merge conflict resolution that was done, given a merge commit SHA1?
提问by Pistos
When you resolve a conflict, then stage the changes, then do a git diff, it shows you two columns of +'s and -'s, one for "ours" and one for "theirs". Given a merge commit in a repo's git history, how do I see that resolution, which was done by someone else? In other instances, I've seen it before (in gitk, I think), but I can't seem to determine it for this SHA1 that I have.
当您解决冲突,然后暂存更改,然后执行 git diff 时,它会向您显示两列 + 和 -,一列代表“我们的”,另一列代表“他们的”。鉴于回购的 git 历史记录中的合并提交,我如何查看由其他人完成的解决方案?在其他情况下,我以前见过它(我认为是在 gitk 中),但我似乎无法为我拥有的这个 SHA1 确定它。
回答by micromoses
If you know the ref, then git show <MERGE_COMMIT>
will show you the resolution done (if any) for the merge commit.
如果您知道 ref,git show <MERGE_COMMIT>
则将向您显示合并提交的解决方案(如果有)。
For log, use git log -p -c
or git log -p --cc
. From the manpage of git log:
对于日志,请使用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.
回答by Philip Oakley
Slight bikeshed: you could use diff3 or kdiff3 to see the merge in reverse, particularly if it was a (git style) 'evil' merge, where a secondary change was introduced to resolve the conflict. (watch out for an exploding head trying to see how it 'backs out' the changes;-)
轻微的自行车棚:您可以使用 diff3 或 kdiff3 来查看反向合并,特别是如果它是(git 样式)“邪恶”合并,其中引入了二次更改来解决冲突。(当心爆炸头试图查看它如何“退出”更改;-)
Obviously the 'base' commit would be the merged commit.
显然,“基本”提交将是合并提交。