What does the caret (^) character mean?

HEAD^ means the first parent of the tip of the current branch.

Remember that git commits can have more than one parent. HEAD^ is short for HEAD^1, and you can also address HEAD^2 and so on as appropriate.

You can get to parents of any commit, not just HEAD. You can also move back through generations: for example, master~2 means the grandparent of the tip of the master branch, favoring the first parent in cases of ambiguity. These specifiers can be chained arbitrarily , e.g., topic~3^2. See related answer to What’s the difference between HEAD^ and HEAD~ in Git?

For the full details, see the “Specifying Revisions” section of git rev-parse --help.


It means "parent of". So HEAD^ means "the parent of the current HEAD". You can even chain them together: HEAD^^ means "the parent of the parent of the current HEAD" (i.e., the grandparent of the current HEAD), HEAD^^^ means "the parent of the parent of the parent of the current HEAD", and so forth.


The ^ (caret) can also be used when specifying ranges.

To exclude commits reachable from a commit, a prefix ^ notation is used. E.g. ^r1 r2 means commits reachable from r2 but exclude the ones reachable from r1.

<rev>

Include commits that are reachable from (i.e. ancestors of) .

^<rev>

Exclude commits that are reachable from (i.e. ancestors of) .

Tags:

Git