^ vs ~ in git HEAD #22165
-
I know HEAD currently points to the latest commit in current branch. I have seen many online blogs some of them are using I checked ~ and ^ has no difference. Please help me understand why git support ^ and ~ if they are same |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The reference for commit expression operators such as |
Beta Was this translation helpful? Give feedback.
The reference for commit expression operators such as
^
and~
is the “Specifying Revisions” section of thegit rev-parse
man page. In general,commit^N
means the Nth parent ofcommit
, whilecommit~N
means the commit reached by following the first parent N times. When N = 1, these are coincidentally the same. But when N is not 1, they are different: for example,commit^2
is the second parent ofcommit
, whilecommit~2
is the first parent of the first parent ofcommit
.