Reference: StackOverflow

  • HEAD~2: 2 commits older than HEAD
  • HEAD^2: the second parent of HEAD, if HEAD was a merge, otherwise illegal
  • HEAD@{2}: refers to the 3rd listing in the overview of git reflog
  • HEAD~~: 2 commits older than HEAD
  • HEAD^^: 2 commits older than HEAD

HEAD~~ and HEAD^^ are equal.


git help revisions:

Here is an illustration, by Jon Loeliger. Both commit nodes B and C are parents of commit node A. Parent commits are ordered left-to-right.

G   H   I   J
\ /     \ /
 D   E   F
  \  |  / \
   \ | /   |
    \|/    |
     B     C
      \   /
       \ /
        A

A =      = A^0
B = A^   = A^1     = A~1
C = A^2  = A^2
D = A^^  = A^1^1   = A~2
E = B^2  = A^^2
F = B^3  = A^^3
G = A^^^ = A^1^1^1 = A~3
H = D^2  = B^^2    = A^^^2  = A~2^2
I = F^   = B^3^    = A^^3^
J = F^2  = B^3^2   = A^^3^2
Comments
Write a Comment