aboutsummaryrefslogtreecommitdiff
path: root/git/git-rename-tag.sh
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2025-10-06 00:48:48 +0300
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2025-10-06 00:48:48 +0300
commitad9e7cd5117c965222aae708f660e56d537914fc (patch)
tree580006656ec76513500170e5646e92e7819c6c0b /git/git-rename-tag.sh
downloadsnippets-ad9e7cd5117c965222aae708f660e56d537914fc.tar.gz
imported all of my Github gists from https://gist.github.com/rhaberkorn
Diffstat (limited to 'git/git-rename-tag.sh')
-rwxr-xr-xgit/git-rename-tag.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/git/git-rename-tag.sh b/git/git-rename-tag.sh
new file mode 100755
index 0000000..282a7ea
--- /dev/null
+++ b/git/git-rename-tag.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# 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