Skip to content

Instantly share code, notes, and snippets.

@darach
Created November 24, 2014 17:27
Show Gist options
  • Save darach/2a6ef3c174222f757a09 to your computer and use it in GitHub Desktop.
Save darach/2a6ef3c174222f757a09 to your computer and use it in GitHub Desktop.
Rename git tags
#!/bin/bash
if [ $# -ne 2 ];
then
echo "usage: $0 <old> <new>";
exit 1
fi
old=$1
new=$2
git tag | grep "$old" > /dev/null 2>&1
status=$?
if [ $status -ne 0 ];
then
echo "error: cannot rename non existant tag $old"
echo "- valid tags are: "
echo "`git tag | awk '{ print \" \" $1 }' 2> /dev/null`"
echo
exit 2
else
git tag $new $old
git tag -d $old
git push origin :refs/tags/$old
git push --tags
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment