Created
May 13, 2009 14:38
-
-
Save knu/111055 to your computer and use it in GitHub Desktop.
How to mass-rename tags and push them with Git
This file contains 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
# Rename tags named foo-bar-#.#.# to v#.#.# and push the tag changes | |
git tag -l | while read t; do n="v${t##*-}"; git tag $n $t; git push --tags ; git tag -d $t; git push origin :refs/tags/$t ; done |
you can greatly speed this up by pushing and pruning all remote tags at once:
# make sure your tags are up to date
git fetch origin
# rename all tags
git tag -l | while read t; do n="v${t##*-}"; git tag $n $t; git tag -d $t; done
# synchronise with the server
git push --tags --prune origin refs/tags/*
you can greatly speed this up by pushing and pruning all remote tags at once:
# make sure your tags are up to date git fetch origin # rename all tags git tag -l | while read t; do n="v${t##*-}"; git tag $n $t; git tag -d $t; done # synchronise with the server git push --tags --prune origin refs/tags/*
no matches found: :refs/tags/*
This changes x.y.z
to x/y/z
, but won't delete tags that are already in new format
# make sure your tags are up to date
git fetch origin
# rename all tags
git tag -l | while read t; do n=$(echo $t | sed "s?\.?/?g"); if [[ "$n" != "$t" ]]; then git tag $n $t; git tag -d $t; git push origin :refs/tags/$t ; done
This changes build/n
to build/0n
(e.g.: build/8
-> build/08
).
git tag -l | while read t; do n=$(echo $t | sed "s?\/?/0?g"); git tag $n $t; git tag -d $t; done
Rename all vx.y.z
tags to x.y.z
:
git tag -l | while read t; do n="${t#?}"; git tag $n $t; git push --tags ; git tag -d $t; git push origin :refs/tags/$t ; done
Don't forget to turn off CI/CD, if it's based on the tags ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Renamed all my
x.y.z
tags tovx.y.z
, thanks!