Skip to content

Instantly share code, notes, and snippets.

@djm
Forked from hugorodgerbrown/remove_tags.sh
Created March 8, 2017 12:38
Show Gist options
  • Save djm/4aeb11c027d5c49305c8fa5aaa984e7c to your computer and use it in GitHub Desktop.
Save djm/4aeb11c027d5c49305c8fa5aaa984e7c to your computer and use it in GitHub Desktop.
Git - remove all remote tags
# removes all tags from a git remote
# 1. `git ls-remote --tags origin` - lists all the tags at origin: '<hash> refs/tags/<tag>'
# 2. `awk '/^(.*)(\s+)(.*[a-zA-Z0-9])$/ {print ":" $2}'` - extract the ':/ref/tags/<tag>' from each
# 3. `xargs git push origin` - run 'git push origin :/ref/tags/<tag>' against each tag
git ls-remote --tags origin | awk '/^(.*)(\s+)(.*[a-zA-Z0-9])$/ {print ":" $2}' | xargs git push origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment