Skip to content

Instantly share code, notes, and snippets.

@noirotm
Created January 18, 2016 10:05
Show Gist options
  • Save noirotm/7d8c22a0c3582eefbc60 to your computer and use it in GitHub Desktop.
Save noirotm/7d8c22a0c3582eefbc60 to your computer and use it in GitHub Desktop.
Script to rename Git tags from X.Y.Z to vX.Y.Z
#!/bin/sh
git for-each-ref --shell --format="ref=%(refname:short)" refs/tags | \
while read entry
do
# assign tag name to $ref variable
eval "$entry"
# test if $ref starts with v
ref2="v${ref#v}"
if [ "${ref}" != "${ref2}" ]; then
# rename/delete tag
git push origin refs/tags/${ref}:refs/tags/${ref2} :refs/tags/${ref}
git tag -d ${ref}
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment