Skip to content

Instantly share code, notes, and snippets.

@reid
Forked from rgrove/delete-tags.sh
Created October 1, 2012 22:06
Show Gist options
  • Save reid/3814760 to your computer and use it in GitHub Desktop.
Save reid/3814760 to your computer and use it in GitHub Desktop.
Shell script to delete useless build tags from GitHub forks of YUI 3
#!/bin/bash
# This script will delete *all* local and remote tags from any git repo you run
# it in that begin with "yui3-". 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
REMOTE='origin'
# 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."
echo
exit 1
fi
echo "--> Cleaning up tags"
# First, delete all old local tags.
git tag -d `git tag | grep "yui3-" | xargs`
# Now fetch all remote tags so we'll know which ones to delete.
git fetch --tags $REMOTE
tags=`git tag | grep "yui3-" | xargs`
# Delete all old remote tags.
if [ "$tags" != "" ]; then
git push -v --delete $REMOTE $tags
fi
# Re-delete all old local tags.
git tag -d $tags
echo "--> Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment