Like most VCSs, Git has the ability to tag specific points in history as being important. Generally, people use this
functionality to mark release points (v1.0, and so on). Git uses two main types of tags: lightweight and annotated.
However, it is highly recommended to use the annotated tags, because they are stored as full objects in the Git database. They’re checksummed; contain the tagger name, e-mail, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG).
- Create a tag
Creating an annotated tag in Git is simple. The easiest way is to specify -a when you run the tag command:
The -m specifies a tagging message, which is stored with the tag. If you don’t specify a message for an annotated tag,
Git launches your editor so you can type it in.
- Show a tag
You can see the tag data along with the commit that was tagged by using the git show command.
- Checkout a tag
You can check out a specific version of the tool by using the command “git checkout v1.0”.
- Delete a tag
You can delete a tag any time if that version is discarded by using the command “git tag –d v1.0”.
The following example shows how to add a tag to the tool, and how to switch between different versions of the tool.
!!!NOTE: Commit first before adding the tag to the tool.
By doing the above procedure, a tag has been added to the tool. Let’s do some modification for the tool and then create
another tag for it.
To see the current version of the tool, use “git describe”.
Now, let’s check out the first version of the tool.
Now the tool has been switched to the version v1.0. Let’s switch back to version 2.0.
For more information about Git, please find the free online book Git Pro here: