Created
November 24, 2014 17:27
-
-
Save darach/2a6ef3c174222f757a09 to your computer and use it in GitHub Desktop.
Rename git tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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