Show conflict diff part of a merge
12,440
Solution 1
Look at the hash (or tag) of the merge commit (the commit that has multiple parents) and do:
git diff hash hash^1 hash^2
It will output a 3 way-diff of the changes.
hash^
(or hash^1
) references the first parent commit of hash
hash^2
references the second parent commit of hash
Solution 2
If you use the standard gitk
tool, and click on a merge commit, the lower left pane shows the conflict resolutions.
Related videos on Youtube
Author by
brauliobo
Updated on September 16, 2022Comments
-
brauliobo over 1 year
I need to present to the team what changes I've made during conflict resolution of a merge.
I know this is kind of hard, but I certainly believe it is possible somehow. I've tried already
git show -m
andgit show -c
. -
twalberg almost 11 yearsIn addition, making that
git diff --cc hash hash^1 hash^2
will format the diff in the same waygitk
displays it. Not sure which output format is preferred by OP, though... Actually, never mind...git diff
does that by default, it seems, when you give it three hashes... -
Klas Mellbourn almost 11 years@brauliobo I would assume by doing
git diff hash hash^1 hash^2
wherehash
is the hash of the merge commit. -
brauliobo almost 11 yearsthank you! made an alias:
dc = "!f() { HASH=$1; shift 1; git d --cc $HASH $HASH^1 $HASH^2 $@; }; f"
-
HelloGoodbye over 9 yearsWhen I use this line, I get
fatal: ambiguous argument 'hash': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: git <command> [<revision>...] -- [<file>...]>
-
KurzedMetal over 9 yearsDude, you have to replace
hash
with a real hash or commit tag of a merge commit... -
stochastic over 6 yearsgreat answer! When I look at the manpage for git diff it doesn't show a variant with three hashes... yet this works for me (git 1.9.1). Is this an undocumented thing? It would be nice if I cound read the docs about this nifty new option.
-
KurzedMetal over 6 years@stochastic TBH, I don't remember, maybe it was in older versions of the documentation?
-
ricab about 2 yearsThis doesn't seem to work for conflicts that were resolved with "ours".