Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Deleting git Tags on a Remote

DZone's Guide to

Deleting git Tags on a Remote

· Java Zone ·
Free Resource

Get the Edge with a Professional Java IDE. 30-day free trial.

For some reason our git repo for Apache Isis (mirrored on github) acquired a bunch of tags in the form:

  • upstream/isis-1.4.0
  • upstream/upstream/isis-1.4.0
  • upstream/upstream/upstream/isis-1.4.0
  • upstream/upstream/upstream/upstream/isis-1.4.0

Clearly something or someone has been accidentally pushing bad tags.

To remove these tags locally, I used:

for a in `git tag -l upstream*`; do echo $a; git tag -d $a ; done

To remove these tags from origin, I chose to do it in two steps. First locate the tags to be deleted:

git ls-remote –tags origin | awk ‘{print $2}’ | \
grep ^refs/tags/ | cut -c11- | \
grep upstream | grep -v "\^{}" \
> /tmp/y

then delete ‘em:

for a in `cat /tmp/y`; do echo $a; git push –delete origin $a ; done

Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}