Git Git revisions syntax Dereferencing branches and tags: ^0, ^{}


In some cases the behavior of a command depends on whether it is given branch name, tag name, or an arbitrary revision. You can use "de-referencing" syntax if you need the latter.

A suffix ^ followed by an object type name (tag, commit, tree, blob) enclosed in brace pair (for example v0.99.8^{commit}) means dereference the object at <rev> recursively until an object of type <type> is found or the object cannot be dereferenced anymore. <rev>^0 is a short-hand for <rev>^{commit}.

$ git checkout HEAD^0    # equivalent to 'git checkout --detach' in modern Git

A suffix ^ followed by an empty brace pair (for example v0.99.8^{}) means to dereference the tag recursively until a non-tag object is found.


$ git show v1.0
$ git cat-file -p v1.0
$ git replace --edit v1.0


$ git show v1.0^{}
$ git cat-file -p v1.0^{}
$ git replace --edit v1.0^{}