How do you see / show a git merge conflict resolution that was done, given a merge commit SHA1?

删除回忆录丶 提交于 2019-11-29 01:48:26

问题


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.


回答1:


If you know the ref, then git show <MERGE_COMMIT> will show you the resolution done (if any) for the merge commit.

For log, use git log -p -c or git log -p --cc. From the manpage of 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.



回答2:


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;-)

Obviously the 'base' commit would be the merged commit.



来源:https://stackoverflow.com/questions/15277708/how-do-you-see-show-a-git-merge-conflict-resolution-that-was-done-given-a-mer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!