kambi
kambi

Reputation: 3423

Finding changes in a Git merge

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?

Upvotes: 0

Views: 64

Answers (2)

1615903
1615903

Reputation: 34722

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.

Upvotes: 1

cexbrayat
cexbrayat

Reputation: 18402

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

Upvotes: 1

Related Questions