When I specify an ancestor commit object in Git, I\'m confused between HEAD^
and HEAD~
.
Both have a \"numbered\" version like HEAD^3<
Here's a very good explanation taken verbatim from http://www.paulboxley.com/blog/2011/06/git-caret-and-tilde :
ref~
is shorthand forref~1
and means the commit's first parent.ref~2
means the commit's first parent's first parent.ref~3
means the commit's first parent's first parent's first parent. And so on.
ref^
is shorthand forref^1
and means the commit's first parent. But where the two differ is thatref^2
means the commit's second parent (remember, commits can have two parents when they are a merge).The
^
and~
operators can be combined.