Search code examples
gittagscommit

git fatal:No tags can describe <sha1 number>


I am using tags by applying them to nightly builds. Then later, I want to use the output of describe --tags --match <latest tag> to tell me how far from the nightly build my images are. This is for QA testing.

I just ran into an error in a clone that is older than the current tag. I ran git fetch --tags, so I see the tag in git tag output, but when I run git describe --tags --match <tagname>, I get fatal: No tags can describe <head sha1 version number>. I cannot do a git pull to update the workspace at this point. Why does this happen and is there a workaround? Thanks very much


Solution

  • It happens because you only fetch the tag, not the commit history of the tag. git describe uses this history, which is why it has an error.

    The only workaround is to fetch repo's history containing the tag you're interested in, using git fetch <remote-name>.