Tuesday, August 28, 2012

Tags in git

Tag a release

Once one is happy with the code and the build, a given commit can be tagged with a proper release tag::

    $ git checkout release

    # Code changes, fixes, build, tests, etc.
    $ git commit -m"Release candidate complete"

    # To view the latest commit hash:
    $ git log
    commit 2e4a6e1a7cc3bf2298055937ab79f72fb58abf1f
    Author: Marco Massenzio
    Date:   Tue Aug 28 22:49:04 2012 -0700

            Release candidate complete

    # Tag it with the appropriate release number
    git tag -m"Rel. 0.6 RC3" rel_0.6rc3 2e4a6e1a

    # Push the commits to origin:
    $ git push origin release

    # The tag will be kept local to the repository, must be pushed too:
    $ git push origin rel_0.6rc3:refs/tags/rel_0.6rc3

When others pull from the remote origin repo, the tag will be pulled too.


A nice feature of github is that it records the tags separately, and clicking on any of them will
cause a download of a 'clean' working directory into a ZIP file or tarball, reflecting the state of
the project at the exact point when the tagged commit was pushed.