Ls-remote reports phantom tags ending with "^ {}"

What are the tags that end with '^ {}'? They actually do not exist in the bare repository.

$ git ls-remote -t origin 55f09717db93733b8f151763e7e28628f3f22129 refs/tags/Init dce13158fff0e95b8adcc5628f193a8c03bada9c refs/tags/Init^{} 2c9f64c306aa76e5b689bc2ffb41163aa255ac40 refs/tags/kaos-red 0970feca84d87df60ec5e943da2f55f1947fd0a3 refs/tags/legacy dce13158fff0e95b8adcc5628f193a8c03bada9c refs/tags/legacy^{} 

When I try to delete them using git push: legacy ^ {} ", for example, git answers

 fatal: remote part of refspec is not a valid name in :Init^{} 

So where are they from? Is this an error in ls-remote?

+7
source share
2 answers

The git rev-parse manual describes various ways to define commits or other objects in git. In this case, it says:

^ {}, i.e. v0.99.8 ^ {} The suffix ^ followed by an empty pair of brackets means that the object can be a tag and play the tag recursively until an object without tags is found.

+7
source

I wanted to massively delete tags in my remote git repository, in some documents I found from Google, I found the command as

 git ls-remote --tag | awk '/(.*)(\s+)(.*)/ {print ":" $2}' | xargs git push origin 

or something like that. (the same problem will show phantom tags ending in ^ {})

If you want to do the same as me, you can try using the git show-ref command

 git show-ref --tag | awk '/(.*)(\s+)(.*)/ {print ":" $2}' | xargs git push origin 

In the latter case, you will not be blocked by this problem.

+2
source

All Articles