Delete all tags from a Git repository

For Windows users using PowerShell:

git tag | foreach-object -process { git tag -d $_ }

This deletes all tags returned by git tag by executing git tag -d for each line returned.


git tag | xargs git tag -d

Simply follow the Unix philosophy where you pipe everything.

On Windows use git bash with the same command.


To delete remote tags (before deleting local tags) simply do:

git tag -l | xargs -n 1 git push --delete origin

and then delete the local copies:

git tag | xargs git tag -d

It may be more efficient to push delete all the tags in one command. Especially if you have several hundred.

In a suitable non-windows shell, delete all remote tags:

git tag | xargs -L 1 | xargs git push origin --delete

Then delete all local tags:

git tag | xargs -L 1 | xargs git tag --delete

This should be OK as long as you don't have a ' in your tag names. For that, the following commands should be OK.

git tag | xargs -I{} echo '"{}"' | tr \\n \\0 | xargs --null git push origin --delete
git tag | xargs -I{} echo '"{}"' | tr \\n \\0 | xargs --null git tag --delete

Other ways of taking a list of lines, wrapping them in quotes, making them a single line and then passing that line to a command probably exist. Considering this is the ultimate cat skinning environment and all.

Tags:

Git

Git Tag