192

How do you remove a git tag that has already been pushed? Delete all git remote (origin) tags and Delete all git local tags.

3 Answers 3

474
  1. Delete All local tags. (Optional Recommended)
    git tag -d $(git tag -l)
    
  2. Fetch remote All tags. (Optional Recommended)
    git fetch
    
  3. Delete All remote tags.
    # Note: pushing once should be faster than multiple times
    git push origin --delete $(git tag -l) 
    
  4. Delete All local tags.
    git tag -d $(git tag -l)
    
14
  • 1
    If you got error message "argument list too long", which you probably would if you're trying to clear tags Use git tag -d $(git tag -l | head 100)
    – tu4n
    Jul 5, 2018 at 3:10
  • 4
    1) clears out all your local tags 2) retrieves all remote tags giving you a complete list of remote tags locally 3) deletes the remote tags with reference to the local list 4) deletes the local tags from step 2
    – sentece
    Feb 27, 2019 at 15:50
  • 4
    minor fix for head syntax git tag -d $(git tag -l | head -n 100) Apr 18, 2019 at 14:34
  • 8
    git tag -d $(git tag -l) fails on git 2.23 with error: switch `l' is incompatible with --delete
    – turbanoff
    Oct 31, 2019 at 12:40
  • 6
    I had 90K local tags, so using head was not acceptable, the syntax that worked for me was git tag -l | xargs -L1 git tag --delete
    – tzachs
    Jul 30, 2020 at 15:44
20

For windows using command prompt:

Deleting local tags:

for /f "tokens=* delims=" %a in ('git tag -l') do git tag -d %a

Deleting remote tags:

for /f "tokens=* delims=" %a in ('git tag -l') do git push --delete origin %a
4
  • 3
    When using PS: git tag -l | %{git tag -d $_} Feb 24, 2020 at 13:29
  • 2
    For local tags: git tag -l | xargs git tag -d
    – LongTP5
    Jul 17, 2020 at 2:40
  • 1
    @LongTP5 - xargs is not native windows command and should be installed additionaly.
    – npocmaka
    Jul 17, 2020 at 10:13
  • Wow, works, but isn't fast at all! About 5 dels per second on local trags deleting.
    – Brambor
    Sep 7 at 7:18
6

The main answer didn't work for me.

This failed:

git push origin --delete $(git tag -l)

Error:

fatal: --delete doesn't make sense without any refs

That's because I had NO local tags!

git tag -l showed nothing, even after running git fetch to supposedly fetch all remote tags!

BUT, the following worked!:

Under certain, rare circumstances, where you have remote tags on GitHub but no local tags, for instance, you may need to manually specify the tags to delete.

Go to https://github.com/YOUR_USERNAME/YOUR_REPO_NAME/tags (ex: https://github.com/ElectricRCAircraftGuy/sublime_gcode/tags) to view all remote tags.

Mine showed tags 1.0.0 and 1.0.1. Delete them manually with:

To delete remote tags manually:

# General format to delete a **remote** tag on remote named "origin"
git push --delete origin <tag_name>

# My case exactly
git push --delete origin 1.0.0
git push --delete origin 1.0.1

To delete local tags manually:

# list all tags
git tag
# OR (same thing): 
git tag -l

# delete a local tag
git tag -d <tag_name>
# Example: delete local tag named `1.0.0`
git tag -d 1.0.0

Source where I learned all of this: https://devconnected.com/how-to-delete-local-and-remote-tags-on-git/

1
  • I'm just getting "remote: Repository not found fatal: repository 'https://...git not found" which seems odd, as via IntelliJ it is working May 19, 2022 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.