Created
January 31, 2019 17:52
-
-
Save rhaberkorn/09fd768428a8dbe849e08312598d5bc3 to your computer and use it in GitHub Desktop.
Rewrite Git tag to new commit, preserving annotations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 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 {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment