I am trying to use git describe to retrieve the latest tag name for the current branch, but I'm facing unexpected warnings in the output.
-> git describe
warning: tag 'v0.0.6' is externally known as 'refs/tags/v0.0.6'
refs/tags/v0.0.6-0-g5392899
-> git describe --tags
warning: tag 'v0.0.6' is externally known as 'refs/tags/v0.0.6'
refs/tags/v0.0.6-0-g5392899
-> git describe --tags --abbrev=0
warning: tag 'v0.0.6' is externally known as 'refs/tags/v0.0.6'
refs/tags/v0.0.6-0-g5392899c48d700b48e0dda16129dac6a60bb3b1e
As indicated, the tags locally do not have the refs/tags prefix:
-> git tag -l
v0.0.1
v0.0.2
v0.0.3
v0.0.4
v0.0.5
v0.0.6
However, I'm not sure why the warning is being received or what I can do about it.
The tags were not deleted and recreated, nor have they been renamed.
The tags are created from our build environment (Jenkins).
Is there something I can do to correct or work around the warning?
-> git show
commit 5392899c48d700b48e0dda16129dac6a60bb3b1e (HEAD -> master, tag: v0.0.6, origin/master, origin/HEAD)
...
-> git --version
git version 2.30.1 (Apple Git-130)
Edit:
Our Jenkins build which creates the tags uses jgit. The configuration for checking out the branch/code is as follows:


I was able to reproduce the same error using
git version 2.25.1. The only difference is that the error message returned is:This warning comes from the
append_namefunction and I guess the problem is thatname_checkedfield is false. I tried to find some logic behind that field but I did not make it, besides I am not that good with C and I would have lost a day at least.The warning you are seeing might be caused by something else, but it came out after I (manually) generated a discrepancy between
.git/packed-refs,.git/refs/tags/1.0and the tag object. Specifically, I created a tag namedrefs/tags/1.0, but I modified the.git/packed-refslike this:However, unlike you, I am not seeing only the correct tag with
git tag -l, but also the forged one.Two advices for you: firstly I would check that those 3 files (
.git/packed-refs,.git/refs/tags/your_tagand the tag object file in.git/objects) do not contain any contradictory reference. In either case, please edit your question with how the Git plugin for Jenkins clones the remote repository. If I am not mistaken, it tries hard to optimize performances by reducing at the minimum the references it checks out (and maybe there is just a bug in the plugin).