Git caret and tilde
I spent a little bit of time playing with Git today, specifically the way that the ^ (caret) and ~ (tilde) work and thought I'd document it here in case I forget.
The short version
If you want a deeper explanation skip down to "The long version".
ref~ is shorthand for
ref~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 for
ref^1 and means the commit's first parent. But where the two differ is that
ref^2 means the commit's second parent (remember, commits can have two parents when they are a merge).
The ^ and ~ operators can be combined.
Here's a diagram showing how to reference various commits using HEAD as the starting point.