Git describe giving different tags

好久不见. 提交于 2019-12-13 12:17:13

问题


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 describe origin

Release_V1.0.0.2-18-gce2b24c

With "git describe --all" and "git describe --tags" I got the right tag.

[root pds_series]# git describe --all

tags/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, Release_v1.0.0.4, master)

Do anyone know the reason behind this ? How can I resolve this issue ?


回答1:


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.

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

and:

git cat-file -t Release_v1.0.0.4

On will probably say "tag" and the other will say "commit".

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


来源:https://stackoverflow.com/questions/13412645/git-describe-giving-different-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!