Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Deprecate old git tags by prefixing them, but keeping their message if one is given.
OLD_NAME="intellicore"
for tag in $(git tag) # cleanup in case of half-done transition
do
if echo $tag | grep "$OLD_NAME"
then git tag -d $tag
fi
done
for tag in $(git tag)
do
if msg=$(git show --oneline $tag | head -3 | tail -1 | grep -v index) # dirty way to select the message of the tag only, not the pointed commit
then
msg="This was an $OLD_NAME tag. It said '$msg'."
else
msg="This was an $OLD_NAME tag. It had no message."
fi
echo "$tag -> $OLD_NAME-$tag : $msg"
git tag "$OLD_NAME-$tag" -m "$msg" $tag
git tag -d $tag
done
# To update a distant repo, use:
#
# WARNING: this will delete ALL of your distant tags. Make sure you have a backup somewhere first.
# for tag in $(git ls-remote --tags origin | cut -f 2)
# do git push origin :$tag
# done
#
# git push --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment