gpt4 book ai didi

git - 相对提交引用

转载 作者:行者123 更新时间:2023-12-02 09:11:35 24 4
gpt4 key购买 nike

当我遇到以下内容时,我正在浏览 Git 类(class)(关于相对提交):

* 9ec05ca (HEAD -> master) Revert "Set page heading to "Quests & Crusades""
* db7e87a Set page heading to "Quests & Crusades"
* 796ddb0 Merge branch 'heading-update'
|\
| * 4c9749e (heading-update) Set page heading to "Crusade"
* | 0c5975a Set page heading to "Quest"
|/
* 1a56a81 Merge branch 'sidebar'
|\
| * f69811c (sidebar) Update sidebar with favorite movie
| * e6c65a6 Add new sidebar content
* | e014d91 (footer) Add links to social media
* | 209752a Improve site heading for SEO
* | 3772ab1 Set background color for page
|/
* 5bfe5e7 Add starting HTML structure
* 6fa5f34 Add .gitignore file
* a879849 Add header to blog
* 94de470 Initial commit

关于与 HEAD (SHA 9ec05ca) 相关的提交,讲师写道:

HEAD^ is the db7e87a commit
HEAD~1 is also the db7e87a commit
HEAD^^ is the 796ddb0 commit
HEAD~2 is also the 796ddb0 commit
HEAD^^^ is the 0c5975a commit
HEAD~3 is also the 0c5975a commit
HEAD^^^2 is the 4c9749e commit (this is the grandparent's (HEAD^^) second parent (^2))

我对 HEAD 的曾祖 parent (HEAD^^^) 感到困惑,我认为它应该是 4c9749e 1a56a81( merge 796ddb0 的父级)。我环顾四周(包括 What's the difference between HEAD^ and HEAD~ in Git? )。但这只会让导师的回答更加困惑。

最佳答案

Confusion about the parents of the merge 796ddb0 (you think it should be 4c9749e or 1a56a81)

没有。当您将分支 heading-update merge 回来时,此时原始头部从 1a56a81 移动到 0c5975a。所以 merge 提交实际上是 merge 两个当前头(0c5975a 和 4c9749e)。结果796ddb0的双亲是0c5975a和4c9749e。

现在,如果你相信了,那么我们可以将图表可视化如下(我只是用提交 ID 替换了星号 (*)),

              9ec05ca
|
db7e87a
|
796ddb0
/\
/ \
0c5975a 4c9749e
\ /
\ /
1a56a81

从上图可以得出以下结论。

HEAD^^^ --> ((HEAD^1)^1)^1
--> ((db7e87a)^1)^1
--> (796ddb0)^1
--> 0c5975a

关于git - 相对提交引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51432398/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com