Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Shell script to delete useless build tags from GitHub forks of YUI 3
# This script will delete *all* local and remote tags from any git repo you run
# it in, unless they begin with "v". Please use it to remove the hundreds of
# build tags from your YUI 3 fork.
# This script will not delete branches; just tags.
set -e
# Verify that we have git 1.7.x.
if [ `git --version | grep "version 1\.7" | wc -l` == "0" ]; then
echo "This script requires git 1.7.x."
exit 1
# Verify that the remote is actually GitHub.
if [ `git remote show $REMOTE | grep | wc -l` == "0" ]; then
echo "The '$REMOTE' remote doesn't appear to be GitHub. Please edit"
echo "this script and set the REMOTE variable at the top to the name of"
echo "your git remote that points to GitHub."
exit 1
echo "--> Cleaning up tags"
# First, delete all old local tags.
git tag -d `git tag | grep "^[^v]" | xargs`
# Now fetch all remote tags so we'll know which ones to delete.
git fetch --tags $REMOTE
tags=`git tag | grep "^[^v]" | xargs`
# Delete all old remote tags.
if [ "$tags" != "" ]; then
git push -v --delete $REMOTE $tags
# Re-delete all old local tags.
git tag -d $tags
echo "--> Done"

This comment has been minimized.

Copy link

lsmith commented Aug 8, 2011

TAGS=`git tag | grep "^[^v3]" | xargs`

will leave the version tags


This comment has been minimized.

Copy link
Owner Author

rgrove commented Aug 8, 2011

Updated, thanks.


This comment has been minimized.

Copy link

davglass commented Aug 30, 2011

In case your tags are only local:

if [ "$tags" != "" ]; then
    git push -v --delete origin $tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.