2

I need to get the diff output between two commits for a specific file.

For the moment, I'm doing this command :

git diff parent-sha child-sha path/to/file

There is my problem : For some commits, there are multiple parent commits and I would like to know how to have only one output instead of having multiple parent commits.

For instance, as you can see at the picture below, the commit 44d637 has multiple parent commits (fa82b1 and 3a76be). I'm searching to have an unique command to have the diff between this commit and his parents.

enter image description here

Git Harpon
  • 171
  • 1
  • 11
  • 2
    Pick one parent and use that hash. Picking the first parent will tell you what changed with respect to the first-parent snapshot; picking the second parent will tell you what changed with respect to the second-parent snapshot. It's your choice as to which is more informative for you. – torek Mar 31 '19 at 21:39

1 Answers1

1

As mentions in "How to review a merge commit" by Phil Haack, you can check out the result of git show

You can add the --cc option to get a combined diff.

But as show here, depending on what you are after, you might still need post-processing.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250