Skip to content

Instantly share code, notes, and snippets.

@ArturT
Last active December 17, 2015 19:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArturT/5662388 to your computer and use it in GitHub Desktop.
Save ArturT/5662388 to your computer and use it in GitHub Desktop.
Ruby script to remove local and remote unnecessary tags.
# pull all remote tags
Kernel.system "git", "pull", "--tags"
tags = `git tag | xargs`
tags_list = tags.split(' ')
# don't remove below tags
good_tags = %w(1.0.0 1.1.0 1.1.0.1 1.1.0.2 v1.1.0.3 v1.1.0.4 v1.1.0.5 v1.1.0.6)
# those tags will be deleted
tags_to_delete = tags_list - good_tags
tags_to_delete.each do |tag|
puts tag
# delete local tag
Kernel.system "git", "tag", "-d", tag
# delete remote tag
Kernel.system "git", "push", "origin", ":refs/tags/#{tag}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment