Created
March 8, 2014 03:12
-
Star
(336)
You must be signed in to star a gist -
Fork
(76)
You must be signed in to fork a gist
-
-
Save okunishinishi/9424779 to your computer and use it in GitHub Desktop.
Delete all git remote tags
git tag -d $(git tag -l) ;
git fetch --tags ; \
git tag -l | grep "test" | (xargs -n 1 git push --delete origin && xargs git tag -d) ; \
- Delete all local tags
- Fetch all remove tags
- loop through and delete the tag that matches your tag pattern
This variant, inspired by @markusressel, deletes all tags from a remote Git repository in a single push using xargs, making it faster and cleaner than deleting them individually.
Script:
REMOTE_NAME=origin
git ls-remote --tags "$REMOTE_NAME" \
| awk '{print $2}' \
| grep -v '\^{}$' \
| xargs -r git push --delete "$REMOTE_NAME"How it works:
REMOTE_NAME=origin→ sets the remote name.git ls-remote --tags "$REMOTE_NAME"→ lists all remote tags, with each line showing<SHA> <refname>.awk '{print $2}'→ extracts the refname (e.g.,refs/tags/v1.0.0).grep -v '\^{}$'→ removes dereferenced annotated tags ending with^{}.xargs -r git push --delete "$REMOTE_NAME"→ deletes remaining tags in a single push.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Worked wonders thanks!