When I specify an ancestor commit object in Git, I\'m confused between HEAD^
and HEAD~
.
Both have a \"numbered\" version like HEAD^3<
Both ~
and ^
on their own refer to the parent of the commit (~~
and ^^
both refer to the grandparent commit, etc.) But they differ in meaning when they are used with numbers:
~2
means up two levels in the hierarchy, via the first parent if a commit has more than one parent
^2
means the second parent where a commit has more than one parent (i.e. because it's a merge)
These can be combined, so HEAD~2^3
means HEAD
's grandparent commit's third parent commit.