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

Try Okta to add social login, MFA, and OpenID Connect support to your Java app in minutes. Create a free developer account today and never build auth again.

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

Build and launch faster with Okta’s user management API. Register today for the free forever developer edition!

Topics:

Published at DZone with permission of Dan Haywood, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}