Home > OS >  During a git merge, how can I see which commit(s) are being merged
During a git merge, how can I see which commit(s) are being merged

Time:10-13

I'm in the midst of a messy conflicted git merge operation. For some reason, I forgot which branches or commits are currently being merged. How can I see a list of commit(s) with which the current merge operation was initiated?

CodePudding user response:

The HEAD revision points at the "left" (receiving) commit—the one which is checked out, while the MERGE_HEAD revision names the commit (or commits—in case of an "octopus merge") which is the "right side"—that is what is being integrated.

You can use the MERGE_HEAD with any Git commans which operates on revisions such as git show, git log etc, or pass it to gitk.

You can get more info from the gitrevisions(7) manual page (run git help revisions).

CodePudding user response:

To add to @kostix' answer :

  • git difftool -d HEAD...MERGE_HEAD (3 dots) will give you a view of what is merged, similar to what Github or other platforms display in their Pull Request view ; this is also what git presents as "their" changes ;
  • git difftool -d MERGE_HEAD...HEAD will show you what changed on the base branch ; git presents this as "our" changes ;
  • git log --oneline --graph --boundary HEAD...MERGE_HEAD will show you all commits since the two branches forked.
  • Related