Git中HEAD ^和HEAD〜有什么区别? [英] What's the difference between HEAD^ and HEAD~ in Git?
问题描述
当我在Git中指定一个祖先提交对象时,我很困惑 HEAD ^
和 HEAD〜
。 b
$ b
两者都有一个编号版本,如 HEAD ^ 3
和 HEAD〜2
。
它们与我看起来非常相似或相同,但是在代字号和插入符号之间是否有区别?
HEAD ^
表示当前分支尖端的第一个父项。
请记住,git提交可以有多个父代。 HEAD ^
是 HEAD ^ 1
的缩写,您还可以在 HEAD ^ 2
等等。
你可以得到任何提交的父母,而不仅仅是 HEAD
。您也可以通过几代人回溯:例如, master〜2
表示主分支尖端的祖父母,在不明确的情况下赞成第一父母。这些说明符可以任意链接
, eg , topic〜3 ^ 2
。
有关完整的详细信息,请参阅<$ c中的指定修订 为了直观地表达这个想法,我们引用部分文档: 以下是Jon Loeliger的插图。提交节点B和C都是提交节点A的父节点。父提交按从左到右的顺序排列。 When I specify an ancestor commit object in Git, I'm confused between Both have a "numbered" version like They seem very similar or the same to me, but are there any differences between the tilde and the caret? Remember that git commits can have more than one parent. You can get to parents of any commit, not just For the full details, see "Specifying Revisions" in the To have a visual representation of the idea let's quote part of documentation: Here is an illustration, by Jon Loeliger. Both commit nodes B and C are parents of commit node A. Parent commits are ordered left-to-right.
这篇关于Git中HEAD ^和HEAD〜有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
GHIJ
\ / \ /
DEF
\ | / \
\ | / |
\ | / |
BC
\ /
\ /
A
A = = A ^ 0
B = A ^ = A ^ 1 = A〜1
C = A ^ 2 = A ^ 2
D = A ^^ = A ^ 1 ^ 1 = A〜2
E = B ^ 2 = A ^^ 2
F = B ^ 3 = A ^^ 3
G = A ^^^ = A ^ 1 ^ 1 ^ 1 = A〜3
H = D ^ 2 = B ^^ 2 = A ^^^ 2 = A〜2 ^ 2
I = F ^ = B ^ 3 ^ = A ^^ 3 ^
J = F ^ 2 = B ^ 3 ^ 2 = A ^^ 3 ^ 2
HEAD^
and HEAD~
.HEAD^3
and HEAD~2
.HEAD^
means the first parent of the tip of the current branch.HEAD^
is short for HEAD^1
, and you can also address HEAD^2
and so on as appropriate.HEAD
. You can also move back through generations: for example, master~2
means the grandparent of the tip of the master branch, favoring the first parent in cases of ambiguity. These specifiers can be chained arbitrarily
, e.g., topic~3^2
.git rev-parse
documentation.
G H I J
\ / \ /
D E F
\ | / \
\ | / |
\|/ |
B C
\ /
\ /
A
A = = A^0
B = A^ = A^1 = A~1
C = A^2 = A^2
D = A^^ = A^1^1 = A~2
E = B^2 = A^^2
F = B^3 = A^^3
G = A^^^ = A^1^1^1 = A~3
H = D^2 = B^^2 = A^^^2 = A~2^2
I = F^ = B^3^ = A^^3^
J = F^2 = B^3^2 = A^^3^2