Deleting git tags on a remote

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
June 02, 2014 apache-isis git