1. Technology
Send to a Friend via Email
You can opt-out at any time. Please refer to our privacy policy for contact information.

Tagging Releases

By

A Git repository represents the entire history of a project. From the initial import to the latest unstable version (the master branch), every version of every file is represented in the repository. Besides branches, Git has a handy way of referring to a specific version of all the files in the repository: tags. A tag simply names a snapshot in the history of the repository. It's most useful for tagging releases, so when you're ready to release version 1.0 of your project, just tag it 1.0 and you can later pull the all the files out in their state at the 1.0 release.

Tagging releases in Git is very simple, assuming HEAD represents the state of the release. Simply issue the command git tag v1.0 (replacing for your version number), and it'll be tagged as v1.0. Tags can be any string, so you can tag anything you want, not just releases. Later, you can pull out any release you want with a few simple commands.

To list the tags in a repository, run the command git tag -l or simply git tag. This is particularly useful to see a history of every release of the project, as well as any other tags the developers have put in there.

Tagging can do a few more useful things, mostly related to releases. First, you can add messages to a tag just like you would to a commit. To make an annotated tag, add the -a switch to the command. Additionally, you'll want to use a -m switch to pass a message on the command line (just like with commits) or the -F file switch to pass a message from a file. The message attached to a tag can be either a simple message about the tag, or more commonly, the entire annotated changelog and release notes for a release.

Additionally, you can create signed releases using the tag command. This is a very useful command, as signed releases are very important for developers releasing software that must be trusted. A signed release can only be created using a private key which isn't stored in the repository, and is closely guarded by the developer. These signed releases can be done by using the -s switch instead of -a.

  1. About.com
  2. Technology
  3. Ruby
  4. Tutorials
  5. Using the Git Version Control Tool with Ruby
  6. Tagging Releases

©2014 About.com. All rights reserved.