This is an old revision of the document!
Overview
A small sample of Git revisions; different ways to refer to commits (using Linux kernel source).
Basic Git revisions
HEAD (commonly the default) refers to the commit at the tip of the current branch:
$ git show $ git show HEAD
Commits are also reflected in branch or tag names:
$ git show master $ git show v4.16
And of course you can always use the full commit ID:
$ git show 0adb32858b0bddf4ada5f364a84ed60b196dbcda
You can use git rev-parse to map a reference to its underlying commit ID:
$ git rev-parse v4.16 3fb78e8be9d9428fbc4c016f8b031b01a6fdd63d $
Ancestral Git revisions
Given any revision, you can refer to its (first) parent, or first grandparent, and so on:
$ git show HEAD $ git show HEAD^ (first parent) $ git show HEAD^^ (first grandparent) $ git show master^ (master's first parent) $ git show v4.16^^^ (v4.16's first great-grandparent)
There's also the tilde notation for brevity:
$ git show v4.16~3 (v4.16's first great-grandparent)