HEAD~4^2 meaning

前端 未结 2 1795
野的像风
野的像风 2021-01-02 10:19

In a Udacity lesson covering relative commit references, it says:

^ indicates the parent commit, ~ indicates the first parent commit

The m

2条回答
  •  有刺的猬
    2021-01-02 10:35

    X~n means: The nth ancestor of X.

    X^ means: The parent of X. This is equivalent to X~1.

    If X has more than one parent, one needs to distinguish between them when using the ^ notation. So X^1 would be the first parent, X^2 would be the second parent, and so on. X^ is equivalent to X^1 (and also equivalent to X~1).

    In your example, starting from commit 9ec05ca, which is HEAD:

    • db7e87a is HEAD~1 (or alternatively HEAD^).
    • 796ddb0 is HEAD~2 (or alternatively HEAD^^).
    • 1a56a81 is HEAD~4 (or alternatively HEAD^^^^, but nobody would use that).
    • e014d91, being the first parent of 1a56a81, is HEAD~5, or HEAD~4^, or HEAD~4^1.
    • f69811c, being the second parent of 1a56a81, is HEAD~4^2.

    Reference

    https://git-scm.com/docs/gitrevisions

提交回复
热议问题