When (if ever) will HEAD ~ and HEAD ^ not be the same commit?

Is there a situation in which HEAD~ and HEAD^ will not be the same commit? More generally, is there any series of mergers or other operations that will cause x~ not be the same as x^ ?

+4
source share
2 answers

No, HEAD ~ and HEAD ^ are synonyms.

HEAD ~ means HEAD ~ 1 by definition.

HEAD ~ 1 means HEAD ^ by definition.

See git rev-parse --help details.

+6
source

HEAD~n is the nth (grandiose) fixation parent (here HEAD) after the first parents

HEAD^n is the nth parent of HEAD

In this way,

HEAD~ is the first parent of HEAD (after the first parents, which is discussed here)

HEAD^ is the first parent of HEAD

So HEAD~ = HEAD~1 = HEAD^1 = HEAD^.

They always point to the same fixation.

Note that with this HEAD~2 is equivalent to HEAD^^ , etc.

+2
source

Source: https://habr.com/ru/post/1380291/


All Articles