0

Using git bisect I found the culprit commit - it is a merge commit (I'm on the master branch)

I'm trying to isolate the buggy code but the merge included some commits from the merged branch and I don't know how can I view the full changes between the merge commit and the commit before it (the previous working commit in the master)

Is there a way to do so in GIT?

kambi
  • 3,291
  • 10
  • 37
  • 58

2 Answers2

1

You can do a git diff with the parents.

The first parent is given with SHA1^ and the second parent with SHA1^2 :

git diff mergeSHA1^ mergeSHA1
git diff mergeSHA1^2 mergeSHA1

You can see the docs of git diff for more details

cexbrayat
  • 17,772
  • 4
  • 27
  • 22
  • You have the order of the arguments backwards, but your commands are basically correct. Using the order `git diff mergeSHA1 mergeSHA1^` will show you a reverse of the changes from the merge commit and the first parent. I think the original poster wants the unreversed changes, which you can get with `git diff mergeSHA1^ mergeSHA1`. –  May 23 '13 at 05:54
1

git diff displays differences between commits. The variation you want is probably this:

git diff [--options] <commit> <commit> [--] [<path>…]

This is to view the changes between two arbitrary <commit>.

So for your case, use sha1 of the merge commit for the other, and sha1 of the commit that you want to compare it to as the other.

git diff <sha1 of the commit to compare to> <sha1 of merge commit>

You could also use ^ operator to compare to parents of the merge commit. sha1^ would be the first parent and sha1^2 would be the second, as explained here.

Community
  • 1
  • 1
1615903
  • 32,635
  • 12
  • 70
  • 99
  • Your answer is basically correct, but you probably want to change the order of the arguments to ` `, since the original order will show the changes in reverse. –  May 23 '13 at 05:57
  • @ColdHawaiian fixed, thanks. I never get it right on the first try :P – 1615903 May 24 '13 at 05:17