I want to delete all the tags (local and remote) in my git repo except the latest one. I have read the posts about deleting all tags but could not find the info about deleting them selectively i.e. delete all tags except the latest one
Somehow I found the answer on Stack Overflow itself. Customized it a bit with my needs.
Delete all remote tags but keep latest
git describe --abbrev=0 --tags `git rev-list --tags --skip=1` | xargs -n 1 git push --delete origin
Delete all local tags but keep latest
git describe --abbrev=0 --tags `git rev-list --tags --skip=1` | xargs -n 1 git tag -d
To delete locally all tags:
git tag -d `git tag | grep -E '.'`
Note: Windows users will need to replace grep -E with findstr
The original solution was found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With