Tuesday, August 14, 2018

Git untag

If you've ever forgotten to rebase your local repository before pushing a tagged commit to master
git push --tags origin master
you'll know the pain of having the push rejected with the tag still applied remotely. In this post by Nathan Hoad, you'll find the needed git commands to remove the remote tag, but it's not that easy to remember.
git tag -d 12345
git push origin :refs/tags/12345

So we're going to make a nice little shell command to do it for you!

First open the global user defined .gitconfig file. From the command line:

  • You can either find the user .gitconfig file location by using git config --list --show-origin and finding it in the wall of text. Then, open the file in your favorite editor, or
  • To load the file directly into your favorite editor, use ~/.gitconfig as the path to the config file. For example, if you have Atom installed, use atom ~/.gitconfig.

Now under the [alias] block (add it if you don't see it), add the untag alias:

  untag = "!sh -c 'git tag -d $0 && git push origin :refs/tags/$0'"

And you're done!

To use the command, use the alias followed by the tag to delete & remove from the remote branch

git untag v1.0.0
You can find a lot more useful git aliases from the Git basics documentation.


  1. Very informative and useful historical post. I see you have a lot of other cool stuff available at your website, simply bookmarking it to check in spare time. Thanks and keep the good work up.

    Office Cleanouts

  2. I must say, this is really an awesome post which you have shared in a simple and easy to grasp way. Thanks for sharing this post.Full Stack Development Company Texas

  3. Leo Oscar
    Thank you so much for this useful information. looking more from your side to update us on more updates and advancements

  4. It was great experience after reading this. thanks for sharing such good stuff with us.
    JavaScript institute in Delhi

  5. This comment has been removed by a blog administrator.