ancestry reference

A way of naming a commit by counting back from another: a tilde and a number walk back that many first parents, and a caret picks which parent.

In more detail

HEAD~1 is the parent of the current commit and HEAD~3 is three commits back along first parents. HEAD^2 means the second parent, which only exists on a merge commit. A caret with braces, as in HEAD^{tree}, instead asks for the object the commit points at.

Example

git rev-parse --short HEAD~1

Related terms

Taught in

References