Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save soomtong/4f75801f8ef1df8d0fad88d13838223e to your computer and use it in GitHub Desktop.
Save soomtong/4f75801f8ef1df8d0fad88d13838223e to your computer and use it in GitHub Desktop.
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@soomtong
Copy link
Author

soomtong commented Oct 3, 2019

https://gist.github.com/mobilemind/7883996#gistcomment-2595836

git alias config steps

$ vi ~/.gitconfig

add git alias into alias scope, if dont have [alias], you need add by yourself

[alias]
        remove-tags = "!f() { git tag -l ${1} | xargs -I % echo \"git tag -d % && git push --delete origin %\" | sh; }; f"

run git alias, add regexp to match tags to delete

git remove-tags <regexp>

if you do not know which regexp is work, recommend use list first

git tag --list

DEMO

$ git tag -a 'v10.0.0'
$ git remove-tags 'v10.0.*'
$ git tag -l

@soomtong
Copy link
Author

soomtong commented Oct 3, 2019

$ git rt 'blob pattern'

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