^ 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-parseman page. In general,commit^Nmeans the Nth parent ofcommit, whilecommit~Nmeans 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^2is the second parent ofcommit, whilecommit~2is the first parent of the first parent ofcommit.