1

Isn't there a way to view the diff of a merge commit in such a way that you see the diff between the two parents at once?

I'm not talking about viewing the diff with parent 1, and then you see the diff with parent 2. The output I am wanting has two columns used on the left. For every line which differs from parent one, column one has a +/- sign. And likewise for parent two.

It would look like this:

   Hello
 - World
-- How are you
+  doing?

In this output, any line which starts with two pluses or minuses means that the merge commit itself introduced the change apart from an automerge.

Can you do this in git?

EDIT:

Here is a related question: How do you see / show a git merge conflict resolution that was done, given a merge commit SHA1?

My use case is the same as that question: I want to see the changes made as a result of resolving merge conflicts.

Community
  • 1
  • 1
Alexander Bird
  • 38,679
  • 42
  • 124
  • 159
  • Are you looking for `git merge-tool` – sehe Jun 03 '15 at 19:29
  • Well, I am looking for a way to see the single diff in the command line. How were you thinking of using merge-tool? – Alexander Bird Jun 03 '15 at 19:32
  • I was thinking out of the box. I don't think there's a tool that happens to cater to your extremely specific non-standard need. I use merge-tool when I need a thing like this. Use it with `k3diff`, `meld`; Vim `fugitive` has very decent behaviour for merges by default, and there's Vim `threesome` (which has been renamed I think) – sehe Jun 03 '15 at 19:33
  • related http://stackoverflow.com/a/379716/85371 – sehe Jun 03 '15 at 19:40

1 Answers1

1

git show seems to do what I want.

In the test git repo I made: https://github.com/Thr4wn/test , here is the output of git show:

$ git show master
commit 5bb48fc7481f973cee9a4441d3466fe513bcd685
Merge: 190fded f678b58
Author: Alexander Bird <alexander.bird@aciworldwide.com>
Date:   Wed Jun 3 15:30:03 2015 -0400

    merged

diff --cc README
index 94954ab,ce01362..363f0a5
--- a/README
+++ b/README
@@@ -1,2 -1,1 +1,3 @@@
  hello
++there
 +world

This is what I was remembering existed somehow.

However, git show (with no -m flag) only shows the changes that are different from both parents. In my case, that's all I'm after. If there are no merge conflicts, then git show will probably have no diff.

Alexander Bird
  • 38,679
  • 42
  • 124
  • 159