gpt4 book ai didi

git - git父编号是如何分配的?

转载 作者:太空狗 更新时间:2023-10-29 14:07:49 26 4
gpt4 key购买 nike

来自 git-rev-parse 的文档:

^, e.g. HEAD^, v1.5.1^0

A suffix ^ to a revision parameter means the first parent of that
commit object. ^<n> means the <n>th parent (i.e. <rev>^ is equivalent
to <rev>^1). As a special rule, <rev>^0 means the commit itself and is
used when <rev> is the object name of a tag object that refers to a
commit object.

我知道 git commits 可以有多个父级,并且这种语法可以用来消除引用哪个父级的歧义,但是什么决定了哪个父级是“第一个父级”或“第二个父级”?是否仅基于 merge 提交时 check out 的提交?

例如,git checkout master; git merge feature 导致 master 成为 parent 1,而 git checkout feature; git merge master 会导致 feature 成为父级 1?还是这里发生了其他事情?

最佳答案

Is it just based on which commit was checked out when the commits were merged?

没错。您可以使用 git showgit cat-file -p HEAD 查看提交的父项。

关于git - git父编号是如何分配的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22612965/

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