Created
March 8, 2014 03:12
-
-
Save okunishinishi/9424779 to your computer and use it in GitHub Desktop.
Delete all git remote tags
YMMV (use carefully):
deletes all (locally known) tags on remote named 'origin'
git push origin $(git tag -l --format=':%(refname)')
you may want to delete the tags locally also, or you might push them again:
git tag -d $(git tag -l)
Worked wonders thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I didn't find a solution anywhere that didn't requre a single
git push
call per tag, so I came up with this variant, which - in my case - reduced the runtime from several hours to several seconds:git push --delete origin $( git ls-remote --tags origin | awk '{print $2}' | grep -Ev "\^" | tr '\n' ' ')
Explanation
git push --delete origin $(...)
: Deletes a tag (or multiple) on origin$( git ls-remote --tags origin | awk '{print $2}' | grep -Ev "\^" | tr '\n' ' ')
: Creates a space delimited string of all tagsgit ls-remote --tags origin
: Prints all tags on the remote origin... | awk '{print $2}' | ...
: Only prints the second column of the previous command output... | grep -Ev "\^" | ...
: Filters out unwantedrefs/tags/mytag^{}
variants (not sure where they come from)... | tr '\n' ' '
: Converts the list into a space delimited stringIt takes advantage of the fact that you can provide multiple tag names in a space delimited string, so it only invokes
git delete
once.