"git describe" ignores a tag

knipknap picture knipknap · Nov 11, 2010 · Viewed 31.5k times · Source

In the following lines:

$ git tag -n1
v1.8        Tagged the day before yesterday
v1.9        Tagged yesterday
v2.0        Tagged today
$ git describe
v1.9-500-ga6a8c67
$ 

Can anyone explain why the v2.0 tag is not used by "git describe", and how to fix this? The v2.0 tag is already pushed, so I am guessing that I can't just delete and re-add it.

Answer

knittl picture knittl · Nov 11, 2010

git describe uses only annotated tags by default. Specify the --tags option to make it use lightweight tags as well.

Make sure you've checked out the correct commit (git rev-parse HEAD). Annotated tags are created with git tag -a. If you do git show <tagname> and you see the commit only, it's a lightweight tag; if you see an additional tag message, it's an annotated tag.