2

After I did a revert commit followed by a merge, another contributor made several (3) commits and I wanted to inspect them using git diff HEAD^^^ HEAD which showed chunks that I was sure were updated by my previous commits. Using git show I came to the conclusion that the revert commit and the content of the merge were not taken into account when using either of the HEAD[^...][~...] shortcuts.

Here are the relevant outputs:

$git log -7
3 hours ago 6bcab3e omglolol jun   <--This branch master where HEAD is
4 hours ago 0682cd5 otherfucking editeur de map jun
4 hours ago 83b61da motherfucking editeur de map jun
5 hours ago caf26e1 Merge branch 'welcome' Nath@Home
5 hours ago 5ddbbd0 Revert "back to menu" Nath@Home
5 hours ago 2cb664c user can go fkin everywhere Nath@Home   <--Made on branch welcome
6 hours ago 06221f9 back to menu jun

$git show HEAD^^
4 hours ago 83b61da motherfucking editeur de map jun
<diff follows...>

$git show HEAD^^^
6 hours ago 06221f9 back to menu jun
<diff follows...>

$git --version
git version 1.8.1.2 <--packaged linux mint 15

As it seems, my understanding of the HEAD... shortcuts seems to be failing here, but I did not find any information on this that goes further than the usual bread and butter cases. Could someone enlighten me on this

nathdwek
  • 145
  • 3

1 Answers1

1

This problem is that after your merged master with the 'welcome' branch, the 'master' branch has two parents, namely the previous commit in 'master', and the latest commit in 'welcome'. So saying "give me the state of the world 3 commits ago" is ambiguous, and by default git shows you the last commit in the unmerged branch. git HEAD^^^^2 will give you the state of the world as it was in the second parent of 'master' before the merge.

see also What's the difference between HEAD^ and HEAD~ in Git? for

Community
  • 1
  • 1
gilsho
  • 921
  • 7
  • 11