Like the ~ modifier, the ^ modifier also accepts an optional number after it.

Rather than specifying the number of generations to go back (what ~ takes), the modifier on ^ specifies which parent reference to follow from a merge commit. Remember that merge commits have multiple parents, so the path to choose is ambiguous.

Git will normally follow the "first" parent upwards from a merge commit, but specifying a number with ^ changes this default behavior.

Enough talking, let's see it in action with some examples.

Before the checkout

Git before checkout


Here we have a merge commit. If we checkout master^ without the modifier, we will follow the first parent after the merge commit.

git checkout master^

After the checkout

Git after checkout


Easy -- this is what we are all used to.

Before the checkout

Git before checkout


Now let's try specifying the second parent instead...

git checkout master^2

After the checkout

Git after checkout


See? We followed the other parent upwards.

Before the checkout

Git before checkout


The ^ and ~ modifiers can make moving around a commit tree very powerful. Even crazier, these modifiers can be chained together! Check this out:

git checkout HEAD~^2~2

After the checkout

Git after checkout


Lightning fast!

To complete this level, create a new branch at the specified destination. Obviously it would be easy to specify the commit directly (with something like C6), but I challenge you to use the modifiers we talked about instead!