Last active
June 21, 2019 12:08
-
-
Save Otiel/e1072dfd720685a75824abb4cd706eaa to your computer and use it in GitHub Desktop.
Bash script to rename a git tag
This file contains 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 | |
oldTag=$1 | |
newTag=$2 | |
tmpTag=$2-tmp | |
echo "* Running command: git tag $tmpTag $oldTag" | |
git tag $tmpTag $oldTag | |
echo | |
echo "* Running command: git tag -d $oldTag" | |
git tag -d $oldTag | |
echo | |
echo "* Running command: git push origin :refs/tags/$oldTag" | |
git push origin :refs/tags/$oldTag | |
echo | |
echo "* Running command: git tag $newTag $tmpTag" | |
git tag $newTag $tmpTag | |
echo | |
echo "* Running command: git tag -d $tmpTag" | |
git tag -d $tmpTag | |
echo | |
echo "* Running command: git push origin $newTag" | |
git push origin $newTag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
This script uses a temporary tag in order to be able to rename tags by changing only the case of the characters. For instance, it is not possible to directly do:
Because that will remove both tags
V1.0.0
andv1.0.0
.Some useful links: