Git Cheat Sheet · Tags
Create a tag
git tag -a <name> -m <message>
A tag is a fixed label placed on a commit, usually to mark a released version such as v1.2.0. Unlike a branch, it does not move. git tag -a v1.2.0 -m "Version 1.2.0" creates an annotated tag, with an author, a date and a message.
What it does
Places a fixed label on a commit, usually to mark a version.
A use case
Version 1.2.0 is ready: you mark the commit that was shipped.
On the command line
git tag -a v1.2.0 -m "Version 1.2.0"- Annotated tag on the current commit (recommended for versions).
git tag v1.2.0- Lightweight tag: just a name, with no message.
git tag -a v1.1.1 <commit>- Tags an old commit.
git tag -l "v1.*"- Lists tags matching a pattern.
git show v1.2.0- Shows the tag and its commit.
In Merathon
- Right-click the commit in the graph → "Create a tag here…".
- Enter the name (v1.2.0) then, if you want, a message.
Frequently asked questions
What is the difference between a lightweight tag and an annotated tag?
An annotated tag is a full Git object, with an author, a date, a message and possibly a signature. A lightweight tag is only a name placed on a commit. For a version, prefer the annotated one.
How do I move a tag?
git tag -f <tag> <commit>, then git push --force origin <tag>. Avoid this for a version already published.