Since I can never remember by heart the list of commands needed to rename a git tag on Github, I wrote a small shell script to automatically run theses commands.

If we look up on Google, we can see that if we want to rename the v1.0.11 tag to 1.0.11, we would do the following :

git tag 1.0.11 v1.0.11
git push --tags
git tag -d v1.0.11
git push origin :refs/tags/v1.0.11


Here is the simple shell script to rename and push git tags :

if [ -z "$1" ] || [ -z "$2" ] ||  [ "$1" == "-h" ]; then
  echo "$(basename "$0") SOURCE_TAG DEST_TAG -- rename and push a git tag"
  exit 1

if [ -d .git ]; then
  # copy the old tag to the new tag
  git tag $2 $1

  # push the new tag to the remote server
  git push --tags

  # delete the source tag
  git tag -d $1

  # delete the old tag from the remote server
  git push origin :refs/tags/$1
  echo "You must be in a git directory"
  exit 1


After installing the script globally (ln -s /usr/local/sbin/mvtag), you just have to run mvtag old_tag_name new_tag_name to rename a tag.


Hope that helps!