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~1Related terms
- revision — Any expression Git accepts as a name for a commit or other object, such as an ID, a branch name, a tag, HEAD or HEAD~2.
- parent commit — The commit that came immediately before another one, recorded by ID inside it.
- merge commit — A commit with two (or more) parents, recording the point where two lines of history were joined.
Taught in
- What A Commit Really Is — Advanced Git Internals & Distributed Workflows
- Committing, And What A Good Message Says — Advanced Git Internals & Distributed Workflows
- Reading History: log, show And diff — Advanced Git Internals & Distributed Workflows
- Ignoring Files, And The Tracked File Trap — Advanced Git Internals & Distributed Workflows
- HEAD, And Why Detached HEAD Is Not An Error — Advanced Git Internals & Distributed Workflows
- Rebase: The Same Work, A Different History — Advanced Git Internals & Distributed Workflows
- Undoing: restore, reset, revert And stash — Advanced Git Internals & Distributed Workflows
- Interactive Rebase: Squash, Reorder, Reword — Advanced Git Internals & Distributed Workflows
- Cherry Picking, Reflog, And Getting Work Back — Advanced Git Internals & Distributed Workflows