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.

Share:
12,440

Related videos on Youtube

brauliobo
Author by

brauliobo

Updated on September 16, 2022

Comments

  • brauliobo
    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 and git show -c.

  • twalberg
    twalberg almost 11 years
    In addition, making that git diff --cc hash hash^1 hash^2 will format the diff in the same way gitk 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
    Klas Mellbourn almost 11 years
    @brauliobo I would assume by doing git diff hash hash^1 hash^2 where hash is the hash of the merge commit.
  • brauliobo
    brauliobo almost 11 years
    thank you! made an alias: dc = "!f() { HASH=$1; shift 1; git d --cc $HASH $HASH^1 $HASH^2 $@; }; f"
  • HelloGoodbye
    HelloGoodbye over 9 years
    When 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
    KurzedMetal over 9 years
    Dude, you have to replace hash with a real hash or commit tag of a merge commit...
  • stochastic
    stochastic over 6 years
    great 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
    KurzedMetal over 6 years
    @stochastic TBH, I don't remember, maybe it was in older versions of the documentation?
  • ricab
    ricab about 2 years
    This doesn't seem to work for conflicts that were resolved with "ours".