git中的^ {}是什么意思?


What does ^{} mean in git?

我在git ls-remote命令的末尾偶然发现了两个奇怪的字符,我想知道这是什么意思?

1
2
0e4c39557ccb6789173c  refs/tags/2011-11-04
966f8df553f18c486820  refs/tags/2011-11-04^{}

您是否知道^ {}是什么意思? 另外,为什么这个git标签似乎重复了?


gitrevisions手册中解释了^{}符号:

1
<rev>^{}, e.g. v0.99.8^{}

A suffix ^ followed by an empty brace pair means the object could be a tag, and dereference the tag recursively until a non-tag object is found.

在这种情况下,-refs/tags/2011-11-04是指向标签对象0e4c39557ccb6789173c的标签。 通过执行refs/tags/2011-11-04^{},我们可以将标签取消引用到最终的非标签对象,在这种情况下,该对象是-966f8df553f18c486820(提交)。 请注意,^{}在应用于非标记对象时是noop。

git show-ref命令可用于查看标签以及最终取消引用的非标签对象:

1
2
3
4
5
6
7
8
9
$ git show-ref --tags
3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c
423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}

$ git show-ref --tags --dereference
3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c
6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{}
055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4
423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}

git show-ref手册中:

1
2
-d
--dereference

Dereference tags into object IDs as well. They will be shown with"^{}" appended.


请注意,git ls-remote具有git 2.8的新过滤器(2016年3月)。

请参见Thomas Gummerer(tgummerer)的提交99c08d4,提交ba5f28b,提交80b17e5,提交40a8852,提交54813bd(2016年1月18日)。
建议:pedro rijo(pedrorijo91)。
(由Junio C Hamano合并-gitster-在commit bd6934a中,2016年2月3日)

这意味着您只能显示带有

1
git ls-remote --refs

Do not show peeled tags or pseudorefs like HEAD in the output.