Skip to content

Instantly share code, notes, and snippets.

@okunishinishi
Created March 8, 2014 03:12
Show Gist options
  • Select an option

  • Save okunishinishi/9424779 to your computer and use it in GitHub Desktop.

Select an option

Save okunishinishi/9424779 to your computer and use it in GitHub Desktop.
Delete all git remote tags
#Delete local tags.
git tag -l | xargs git tag -d
#Fetch remote tags.
git fetch
#Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
#Delete local tasg.
git tag -l | xargs git tag -d
@mike-clark-8192
Copy link

mike-clark-8192 commented May 7, 2024

YMMV (use carefully):

deletes all (locally known) tags on remote named 'origin'

git push origin $(git tag -l --format=':%(refname)')

you may want to delete the tags locally also, or you might push them again:

git tag -d $(git tag -l)

@Somfic
Copy link

Somfic commented Jun 20, 2024

Worked wonders thanks!

@rohitvipin
Copy link

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

@xtqqczze
Copy link

xtqqczze commented Oct 1, 2025

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:

  1. REMOTE_NAME=origin → sets the remote name.
  2. git ls-remote --tags "$REMOTE_NAME" → lists all remote tags, with each line showing <SHA> <refname>.
  3. awk '{print $2}' → extracts the refname (e.g., refs/tags/v1.0.0).
  4. grep -v '\^{}$' → removes dereferenced annotated tags ending with ^{}.
  5. 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