Created
August 20, 2018 14:46
-
-
Save boxrick/f0bac46ab90f8ec8f5e3f0512e049252 to your computer and use it in GitHub Desktop.
Rename git tag from old to new. Local and upstream
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
# Simple script to remove the pre-pended 'v' from current git repo and push this upstream. | |
for old_tag in $(git tag) | |
do | |
# remove v from tag | |
new_tag=$(echo "${old_tag//v}") | |
# If the tags don't match then do our rename | |
if [ "$old_tag" != "$new_tag" ] | |
then | |
echo 'Tags dont match, removing pre-pended v' | |
echo "$old_tag $new_tag" | |
# Copy tag | |
git tag $new_tag $old_tag | |
# Push new tag | |
git push --tags | |
# Delete old from local and remote | |
git tag -d $old_tag | |
git push origin :refs/tags/$old_tag | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment