aboutsummaryrefslogtreecommitdiff
path: root/git/git-move-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-move-tag.sh
downloadsnippets-ad9e7cd5117c965222aae708f660e56d537914fc.tar.gz
imported all of my Github gists from https://gist.github.com/rhaberkorn
Diffstat (limited to 'git/git-move-tag.sh')
-rwxr-xr-xgit/git-move-tag.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/git/git-move-tag.sh b/git/git-move-tag.sh
new file mode 100755
index 0000000..05e82be
--- /dev/null
+++ b/git/git-move-tag.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+# git-move-tag <tag-name> <target>
+
+tagName=$1
+# Support passing branch/tag names (not just full commit hashes)
+newTarget=$(git rev-parse $2^{commit})
+
+git cat-file -p refs/tags/$tagName |
+sed "1 s/^object .*$/object $newTarget/g" |
+git hash-object -w --stdin -t tag |
+xargs -I {} git update-ref refs/tags/$tagName {}