Paul Calnan's Blog
Published May 10, 2020

I can never remember the commands to delete a Git tag. It's one of those things I don't do frequently enough to remember — I always have to look it up.

To delete a local tag called TAGNAME:

$ git tag --delete TAGNAME

To delete a remote tag called TAGNAME:

$ git push --delete origin TAGNAME

But rather than have to enter in two commands, I wrote a script that combines them:

#!/usr/bin/env bash

set -euo pipefail

if [ $# -ne 1 ]; then
    echo "Usage: $(basename $0) tag-name"
    exit $E_BADARGS


# Delete the local tag
echo "Deleting local tag $tagname"
git tag --delete $tagname

# Delete the remote tag
echo "Deleting remote tag $tagname"
git push --delete origin $tagname

That script is saved in my ~/bin directory under the name git-rmtag. Using that naming convention, you can run it like this:

$ git rmtag TAGNAME

and it will delete the local and remote tags.