Answer the question
In order to leave comments, you need to log in
Difference between @~ and @^?
What is the difference between @^ and @~ , how can I use it? For example, when reset or rebase
Answer the question
In order to leave comments, you need to log in
These symbols are absolutely identical. Used for relative links back in history from some point.
For example git reset HEAD^3 will switch the current branch three commits back from the current state.
The difference is described in the documentation .
In particular @^
, and @~
indeed quite randomly, they choose the same thing, but they have a different meaning.
@
synonym in this context HEAD
.
^
(=== ^1
) - select the first parent of the commit. Most commits don't have anything else, so numbers other than 1 only make sense for merge commits.
~
(=== ~1
) - select a parent (if there are several, then the first one is selected).
But, for example, @^3
choose the third parent of a commit. In 99.99% of cases, this will be a mistake, because in wildlife there are practically no more than two parents.
But it @~3
means to choose the "great-grandfather" of the commit and this is equivalent to writing @^1^1^1
(or@^^^
).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question