I've started a merge, but it had conflicts which I've resolved, and now it's all staged ready for commit. I just want to double-check which parent revisions I've merged.
Things tried so far:
git show
with the %P format specifier - except I cannot figure out how to get it to tell me the parents of the uncommitted mergegit rev-list
with various options, to no avail- googling for a git equivalent to
hg parents
, which brings me back togit rev-list
but with no success: it lists five revisions, and it fails to list the revision I actually passed togit merge <rev>
git commit
and look at the commit message
The last one is the only option that really kind of worked, except it only shows one of the parents of my uncommitted merge.
There's got to be a better way than git commit
! How do I do this properly?
Note that, because the merge commit doesn't exist yet, you won't be able to use
git log
orgit show
with the%P
format specifier (which corresponds to parent hashes) to access the parents of that future merge commit.Simple merge
In case of a simple merge of one branch into another, you can run
which will print the full SHAs of
respectively.
Octopus merge
If any conflict arises during an octopus merge, which involves merging more than one branch into another, Git will abort the merge; therefore, your question wouldn't normally apply to that case. As pointed out by Andrew in his comment, though, the
--no-commit
flag can be used to intentionally interrupt the merge, even if it's free of conflicts. However, in that case, runningwill only print the SHA of one of the branches being merged in; it won't list the SHAs of all of those branches.
Everything's not lost, though; there is a way of printing all of them. It turns out that the
.git/MERGE_HEAD
file contains the SHAs of all the branches being merged; therefore, a more robust approach consists in simply dumping the contents of that file:To fix ideas, here is a (voluntarily contrived) example of an interrupted octopus merge: