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.

3 thoughts on “How to tag a release in Git

  1. To switch between tags you can first list which ones are available (git tags) and then switch to a particular one by using git checkout, followed by the tag name. For example:

    This is helpful if you’d like to examine code of past releases. Note that when you do this Xcode will tell you you’re “detached” from the commit (under Source Control).

    To go back to the latest revision, head over to Source Control, select Switch to Branch and choose your current working branch.

  2. To push tags to GitHub.com, using “git push origin” does not make them show up in the web interface. Instead, push them with

    and see all your hard work as “releases” at GitHub.com. Note that this does not include titles or descriptions. they still need to be set on the web (as far as I know).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.