Skip to content

Instantly share code, notes, and snippets.

@deichcode
Forked from jloveland/rename-tag
Last active July 25, 2018 14:39
Show Gist options
  • Save deichcode/00ffac71b56954173e6a61a499c5c3ba to your computer and use it in GitHub Desktop.
Save deichcode/00ffac71b56954173e6a61a499c5c3ba to your computer and use it in GitHub Desktop.
rename a git tag
#!/bin/bash
if [ -z "$1" ]
then
echo "enter old tag: "
read old
else
old="$1"
fi
if [ -z "$2" ]
then
echo "enter new tag: "
read new
else
new="$2"
fi
echo "old tag: " $old
echo "new tag: " $new
read -r -p "Are you sure? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
then
echo "Renaming tag"
git tag $new $old
git tag -d $old
git push origin :refs/tags/$old
git push --tags
else
echo "Exiting..."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment