Skip to content

Instantly share code, notes, and snippets.

@Geekfish
Last active December 16, 2015 15:59
Show Gist options
  • Save Geekfish/5459623 to your computer and use it in GitHub Desktop.
Save Geekfish/5459623 to your computer and use it in GitHub Desktop.
Mass delete git tags
# [1] Grab all tags from remote and put them in a file removing the last 15
# Last chance to review...
git ls-remote --tags origin | awk '/^.+?\s+([^{}]+)$/ {print ":" $2}' | sed -n -e :a -e '1,15!{P;N;D;};N;ba' > remote_tags.txt
# [2] Delete remote tags
cat remote_tags.txt | xargs git push origin
# [3] Delete all local tags and refetch the ones that remain on the remote
git tag -l | xargs git tag -d
git fetch
# for newer git versions you can also run
# git fetch --prune --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment