Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

What are the tags that end with '^{}'? They don't actually 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 with "git push :legacy^{}" for example, git responds

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

So where are they coming from? Is it a bug in ls-remote?

like image 451
Lawrence I. Siden Avatar asked Feb 05 '13 16:02

Lawrence I. Siden


2 Answers

The git rev-parse manual describes the various ways you can specify commits or other objects in git. For this case it says:

^{}, e.g. v0.99.8^{} A suffix ^ followed by an empty brace pair means the object could be a tag, and dereference the tag recursively until a non-tag object is found.

like image 107
patthoyts Avatar answered Oct 01 '22 12:10

patthoyts


I wanted to bulk delete tags in my remote git repository, in some result documents I found from Google, I found the command like

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

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

If you want to do the same thing like me, you can try to use the git command show-ref

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

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

like image 37
Charles Avatar answered Oct 01 '22 12:10

Charles