What does the caret (^) character mean?

前端 未结 8 936
广开言路
广开言路 2020-11-29 17:24

I saw an answer to a question here that helps restore a deleted file in git.

The solution was

git checkout ^ -- 

        
8条回答
  •  被撕碎了的回忆
    2020-11-29 18:16

    Here's a visual explanation. Suppose you have a history like so:

                          master  
      ... <- B <- C <- D
                 /
    ... <- E <- F
                  feature
    

    When feature was merged into master, C was created with two ancestors. Git assigns these ancestors numbers. The mainline ancestor B is assigned 1 and the feature ancestor F is assigned 2.

    Thus C^1 refers to B and C^2 refers to F. C^ is an alias for C^1.

    You would only ever use ^3. if you had performed a merge of three branches.

提交回复
热议问题