Mastodon

The many ways of selecting commits, sets of commits, and other references (e.g., branches) in git.

  • ref^{/text} - newest ancestor of ref with commit message matching text
  • :/text- newest commit anywhere with commit message matching text
    • :/!-text - negative match
  • ref@{date}, e.g. main@{yesterday} - the value of ref at a given point in time
  • ref@{n}, e.g. main@{2} - value of ref , n changes ego.
    • that’s HEAD{2}, HEAD{3}, … seen in git reflog
  • @{n}, e.g.@{2} - current branch value 2 changes ago
  • @{-n}, e.g. @{-2} - n-th branch/commit checked out before current
  • branchname@{upstream}, short: branchname{u} - the upstream of branchname
    • @{u} - the upstream of current branch. I often use it in git reset '@{u}' or git rebase '@{u}
  • ref^2 - 2nd parent of ref
  • ref~2 = ref~~ = ref^^ - 2 commits before ref
  • ref^{} - dereference a tag to find a non-tag (i.e., commit)

Revision ranges

git log lists the sum of commit sets, usually each being the set of commits reachable from the git log argumets. But there are other operators:

  • ^ref - exclude commits reachable from ref. Therefore, git log ^origin/master HEAD is the same as git log origin/master..
  • ref^@ - all parents of ref but not ref itself

Sources

  • man gitrevisions