Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mijdavis2/8f774a6b87295ee79b9be1f0820543e5 to your computer and use it in GitHub Desktop.
Save mijdavis2/8f774a6b87295ee79b9be1f0820543e5 to your computer and use it in GitHub Desktop.
Remove the v from git tags
# Fetch
git fetch
# Create tags without v from tags that start with v
for tag in $(git tag)
do
if [[ $tag =~ ^v.*$ ]]
then
git tag "${tag/v/}" $tag
fi
done
# Remove tags that start with v
for tag in $(git tag)
do
if [[ $tag =~ ^v.*$ ]]
then
git tag -d $tag
fi
done
# Push empty (delete) tags that start with v to remote
for tag in $(git tag)
do
# TODO: only push empty (delete) tags we care to delete.
# This currently takes forever.
git push origin :refs/tags/v$tag
done
# Push new "v-less" tags to remote
git push --tags
@mijdavis2
Copy link
Author

Can use the following to check local vs remote tags:

for i in "^v.*$"; do git tag -l | grep "$i" ; git ls-remote --tags origin | awk '{print ":"$2}' | grep "^:refs/tags/v.*$" | grep -v '{}' ; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment