Skip to content

Instantly share code, notes, and snippets.

@rhaberkorn
Created January 31, 2019 17:54
Show Gist options
  • Save rhaberkorn/ed324a974a7d8fe4a1ec1dde55d60daa to your computer and use it in GitHub Desktop.
Save rhaberkorn/ed324a974a7d8fe4a1ec1dde55d60daa to your computer and use it in GitHub Desktop.
Rename an existing remote and local tag at the same time
#!/bin/bash
# git-rename-tag <old-name> <new-name>
# NOTE: This works on the "origin" remote and preserves
# annotations.
set -e
# Creates a new tag on the remote AND removes the old tag
git push origin refs/tags/$1:refs/tags/$2 :refs/tags/$1
# Remove the old local tag
git tag -d $1
# Fetch the new tag
git fetch origin refs/tags/$2:refs/tags/$2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment