Removing tags on Github / by Paulo Fierro

I love git and Github but I don't have any git-fu, as in I don't know how to use the command line version of git to save my life.

Don't get me wrong, I'm fine using the Terminal and for some tasks I even prefer it. But for version control, a GUI does it for me and in this case my app of choice is Tower.

And while Tower is great, and the web interface on Github is good too I recently ran into something I couldn't do with either (or I couldn't figure out).

Deleting tags.

I use tags all the time. Bookmarking commits — what's not to like? For simple things like "this is version 1.1" which we can come back to and branch off of if we need ship a bugfix for 1.1, while at the same time developing new features on the main branch. And for things like "this is where I was before that sketchy merge".

For the first example, this is probably a tag we want to keep and add some release notes. But for the latter, we might want to delete it when we're done. Once we've done testing and QA and everything is good we can nuke that sucka.

So in Tower you can right-click a tag and delete it but if I then push and check "Push All Tags" the tag doesn't get deleted. The next time I pull that tag will come back because I didn't delete it from Github.

We can do this on the command line as follows:

  1. Delete the sketchy tag locally: git tag -d sketchy
  2. Delete the tag on Github: git push origin :sketchy
  3. Push the change: git push --tags

If you added any release notes (and you should) they'll now show up under your project's releases as drafts that are no longer tied to a tag (because you deleted it). To remove it, click to edit it and then Delete Draft.