Skip to content

Instantly share code, notes, and snippets.

@cpetschnig
Created December 16, 2014 08:00
Show Gist options
  • Save cpetschnig/c2dfbc7a4890635bd362 to your computer and use it in GitHub Desktop.
Save cpetschnig/c2dfbc7a4890635bd362 to your computer and use it in GitHub Desktop.
Git tag operations
# fetch remote tags:
$ git fetch --tags origin
# list all remote tags:
$ git ls-remote --tags
# list all major version tags:
$ git ls-remote --tags | grep -oe "refs/tags[^\^]*" | uniq | grep -E "v2[0-9][0-9][0-9]-[0-9][0-9]$"
# delete all non-version tags:
$ git ls-remote --tags | grep -oe "refs/tags[^\^]*" | uniq | grep -vE "v2[0-9][0-9][0-9]-[0-9][0-9]" | xargs git push --delete origin
# delete all RCs:
$ git ls-remote --tags | grep -oe "refs/tags[^\^]*" | uniq | grep -E "v[0-9][0-9][0-9][0-9]-[0-9][0-9].*rc[0-9][0-9]$" | xargs git push --delete origin
# only keep tags locally that are remote:
$ git tag -l | xargs git tag -d && git fetch --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment