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

HEAD is a pointer at the current branch. I have seen a variety of notations for ancestors of HEAD including

  • HEAD~2
  • HEAD^2
  • HEAD@{2}
  • HEAD~~
  • HEAD^^

What does each of the above mean, exactly? Where is the documentation for this?

  • how to get a list of merged files in git?
  • How to 'git blame' on the remote-side repository?
  • Git - discard added files
  • Multiple projects in one git repo?
  • Whats the best way to clone / duplicate a project into a new with git?
  • Git global ignore not working
  • Can I use GitHub's 2-Factor Authentication with TortoiseGit?
  • Update sensitive code on Github and server?
  • How to gitignore *only* files?
  • git finding unmerged branches
  • Re-indexing repository in eclipse Ubuntu
  • .gitignore exclude folder but include specific subfolder
  • One Solution collect form web for “HEAD~ vs HEAD^ vs HEAD@{} also known as tilde vs caret vs at sign”

    • 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

    Documentation can be found here.

    Git Baby is a git and github fan, let's start git clone.