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:

git tag -a v1.1 -m 'Version 1.1'

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

git tag

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:

git log --pretty=oneline

bd75bbfcee6de546c5c0dbb62387241b534481c8 added Season 1
a646c0bfd8c84087b6a37b77352761d84a6d57af added pictures
e9e2732cffe5ce81eb401e78e529f946ccdac226 wish I tagged this
152996254bee69fc3caf7e5c703e7ebaabd4afd4 Initial Commit

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:

git tag -a v1.2 -m 'Version 1.2' e9e273

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:

git push Remote v1.2

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:

    git tag 
    git checkout v1.1

    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, using “git push origin” does not make them show up in the web interface. Instead, push them with

    git push --tags

    and see all your hard work as “releases” at 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.