Delete multiple git remote tags and push once

To delete locally multiple tags: git tag:

git tag -d <tagname>...

So simply:

git tag -d TAG1 TAG2 TAG3

To delete multiple tags remotely: git push:

git push [-d | --delete] [<repository> [<refspec>...]]

So simply:

git push ${REMOTE_NAME:-origin} --delete TAG1 TAG2 TAG3

TL;DR:

git tag -d TAG1 TAG2 TAG3
git push origin -d TAG1 TAG2 TAG3

It will delete all matching tag patterns.

//Delete remote:
git push -d origin $(git tag -l "tag_prefix*")

// Delete local:
git tag -d $(git tag -l "tag_prefix*")

// Examples:
git tag -d $(git tag -l "v1.0*")
git push -d origin $(git tag -l "*v3.[2]*-beta*")

if you have too many tags (like in our case) you might want to do it like:

git tag -l > tags_to_remove.txt

then edit the file in your preferred editor - to review and remove the tags you want to keep (if any) and then run it locally

git tag -d $(cat ./tags_to_remove.txt)

and remotely:

git push -d origin $(cat ./tags_to_remove.txt)

Tags:

Git

Tags