Saturday, October 23, 2010

Adding and deleting git tags

Adding a git tag

Common Case:

Johnny is the developer on a project that is about to go-live. Their codebase has passed all unit tests and functional/behavioural tests from QA. Before going live, he needs to tag the current revision so that his whole team can easily backtrack and possibly fix any last minute bugs before launch but also make it so that his team can also keep pushing code to the master branch.

Create the tag:
$ git tag -a v1.0.0 -m "2010-10-10 Production-Ready"

Double check which tag was created:
$ git describe --tags

Push tags to your repository
$ git push --tags

Deleting a git tag

Common Case:

Johnny accidentally created a tag called "v1.9.0" instead of "v1.0.0". He needs to simply delete this tag so it doesn't confuse other developers.

Delete the tag
$ git tag -d v1.9.0
Push the deletion of the tag to your repository
$ git push origin :refs/tags/v1.9.0


Good luck and have fun,
Jaime Bueza

Jaime Bueza is a software developer in Vancouver, British Columbia, Canada. He has developed web applications for Nintendo, Electronic Arts, Ritchie Brothers, Kiwi Collections, Cox Communications and Microsoft. When he's not developing useful software that constantly evolves with business requirements, he's creating tutorial videos for aspiring front-end developers.
Post a Comment