How to tag a release in Git

Git-Logo-2ColorLike in Subversion, Git supports tags. Most developers use tags to “freeze” a bunch of files at a moment in time, much like a snapshot. Commonly this feature is used whenever a new release of your software is… well… released.

Xcode does not support this feature via the GUI, but of course Git does. Let’s see how to do this from the command line.

Tagging the current branch

You can create a tag from whatever you’ve just committed, no matter which branch this is on. Simply head over to your project and type the following:

This will create a tag called “v1.1″ with the comment “Version 1.1″. To see a list of all your tags, type

Tagging a previous commit

If you’ve forgotten to create a tag from an earlier commit you can do that too. Simply specify part of that ugly long hash Git creates with every commit. They’re not easy to remember of course, so let’s list each commit to find the one you need:

Say you wanted to create a tag from the second commit, the one that reads “wish I tagged this”. Tag it just like above, but add the first few hash digits like so:

Pushing Tags to a remote

Just like branches, your tags are not automatically pushed to a remote. You must specify this explicitly. You also need to know what your remote is called. Let’s assume it’s called “Remote”, here’s how you’d push the tag we’ve just created:

For a more detailed explanation, check out this excellent article from Git SCM.

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

Add your voice!