HEAD~ vs HEAD^ vs HEAD@{} also known as tilde vs caret vs at sign

From the docs here.

  • HEAD~2 : 2 commits older than HEAD
  • HEAD^2 : the second parent of HEAD, if HEAD was a merge, otherwise illegal
  • HEAD@{2} : refers to the 3rd listing in the overview of git reflog
  • HEAD~~ : 2 commits older than HEAD
  • HEAD^^ : 2 commits older than HEAD

If HEAD was a merge, then

  • first parent is the branch into which we merged,
  • second parent is the branch we merged.

Some Combinations and Synonyms

First Parent    First Grandparent    Second Parent    Second Grandparent

HEAD~
HEAD^
HEAD~1          HEAD~2               HEAD^2           HEAD^2~        
HEAD^1          HEAD^^                                HEAD^2^ 

Leave a Comment