3 ms·
HEAD~1 and HEAD^1 are equivalent, but HEAD~n and HEAD^n aren't. HEAD~n means "the n-parent of HEAD, always choosing the first parent." So HEAD~3 means the firs
by djur 13y ago
HEAD~1 and HEAD^1 are equivalent, but HEAD~n and HEAD^n aren't.
HEAD~n means "the n-parent of HEAD, always choosing the first parent." So HEAD~3 means the first parent of the first parent of the first parent of HEAD.
HEAD^n means "the nth parent of head". git commits can have multiple parents if they are merges. So HEAD^3 means the third parent of HEAD.
As a result, HEAD~1 means "the first parent of HEAD" and HEAD^1 means "the first parent of HEAD", but the 1 means two completely different things.
The gitrevisions manpage is pretty mindblowing: https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html https://www.kernel.org/pub/software/scm/git/docs/gitrevision...