git描述给不同的标签 [英] Git describe giving different tags
问题描述
我已经用标记"Release_V1.0.0.4"标记了我的存储库.但是这是我从"git describe"和"git describe origin"中得到的.
I have tagged my repository with the tag "Release_V1.0.0.4". But here is what I got from "git describe" and "git describe origin".
[root pds_series]#git describe
Release_V1.0.0.2-22-g0859de9
[root pds_series]#git描述来源
Release_V1.0.0.2-18-gce2b24c
使用"git describe --all"和"git describe --tags",我得到了正确的标签.
With "git describe --all" and "git describe --tags" I got the right tag.
[root pds_series]#git describe --all
标签/Release_v1.0.0.4
[root pds_series]#git describe --tags
Release_v1.0.0.4
此外,通过以下命令,我得到了正确的标签.
Also, with following command I got the right tag.
[root pds_series]#git log --pretty = format:'%ad%h%d'--abbrev-commit --date = short -1
2012-11-15 0859de9(HEAD,版本_v1.0.0.4,主版本)
有人知道这背后的原因吗?我该如何解决这个问题?
Do anyone know the reason behind this ? How can I resolve this issue ?
推荐答案
您可能使用了轻量级"标签.默认情况下,git describe
仅使用标记对象来描述提交,而对于--tags
,它将使用refs/tags
下的任何引用,即使它们直接指向提交而不是标记对象也是如此.
You probably used a "lightweight" tag. By default git describe
only uses tag objects to describe a commit whereas with --tags
it will use any reference under refs/tags
even if they point directly to a commit rather than a tag object.
要创建标签对象,必须对git tag
使用-a
(带注释)或-s
或-u
(带符号)选项之一,否则,轻量级标签(直接指向提交的引用)将被创建.
To create a tag object you must use one of -a
(annotated) or -s
or -u
(signed) options to git tag
, otherwise a lightweight tag (a reference pointing straight to a commit) will be created.
要查看两个标签之间的区别,请尝试:
To see the difference between your two tags try:
git cat-file -t Release_V1.0.0.2
和:
git cat-file -t Release_v1.0.0.4
打开时可能会说标签",而另一个会说提交".
On will probably say "tag" and the other will say "commit".
要解决此问题,您可以使用-f
和(例如)-a
重新创建标签.
To resolve the issue you can recreate the tag with -f
and (say) -a
.
git tag -f -a Release_v1.0.0.4 Release_v1.0.0.4
这篇关于git描述给不同的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!