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?

0

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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.

2 Comments

Your answer is basically correct, but you probably want to change the order of the arguments to <sha1 of the commit to compare it to> <sha1 of merge commit>, since the original order will show the changes in reverse.
@ColdHawaiian fixed, thanks. I never get it right on the first try :P

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.