Adding and Removing Tags on GitHub

If you’ve accidentally committed a tag and pushed it up to GitHub, it’s quite easy to delete it and then add a new one. For this example, I’m deleting my previous tag “v1.0”, and then adding a new one for the repo at its current state.

1) Delete the v1.0 tag locally:

git tag -d v1.0

2) Delete the v1.0 tag on GitHub (which removes its download link):

git push origin :v1.0

3) Add a new tag for the updated release:

git tag -a v1.0 -m "Version 1.0 Stable"

4) Push the latest tag to GitHub (two dashes):

git push --tags
Comments

12 responses to “Adding and Removing Tags on GitHub”

  1. Thanks for this, helped out a lot.

  2. Ha! Just found a use for this, thanks! (I accidently tagged a repo before committing some changes, so the tagged version wasn’t correct. Just deleted and then re-tagged it – quite handy!)

  3. Step 2 should be replaced by

    git push origin :refs/tags/v0.4

    See http://nathanhoad.net/how-to-delete-a-remote-git-tag

    1. Doesn’t matter. Both means the same.

      1. Not really the same one infers a link to some reference by that name be it a branch or tag. If you have a branch and tag with the same name it will not work.

        Ben Carter Avatar
        Ben Carter
  4. This just solved a frustrating issue I had with deleting remote tags – thanks for posting (even though it was a while ago).

  5. Since the tag being deleted (locally and remotely) is supposed to be “v1.0”, shouldn’t the second step reference v1.0 instead of v0.4? For example:
    git push origin :v1.0

    1. Thanks! I updated the post at some point and had a typo. Fixed.

      1. Glad to help. However, now it says “v0.1” rather than “v1.0”.

  6. Can any one tell me proper way of creating tags. As per my requirement I want to create tag with some name V1. And in that tag V1, I want to commit and push changes made by developer. Is it possible. Or I am going in wrong direction.

    Santosh Yadav Avatar
    Santosh Yadav
  7. Is it possible to delete tag using the GitHub GUI?

Leave a Reply

Your email address will not be published. Required fields are marked *