Create a Tag
git tag -a v1.2.0 -m "Release 1.2.0"This creates an annotated tag on the commit you are on. Without -m, Git opens your editor for the message. For a quick private marker, a lightweight tag needs only a name:
git tag before-upgradeLightweight and Annotated Tags
| Type | What it stores |
|---|---|
| Lightweight | Only a name for a commit |
| Annotated | Name, tagger, date, message |
A lightweight tag is like a branch that never moves. An annotated tag is a separate object in the repository with its own tagger, date, and message, and it can be signed. Use annotated tags for releases and anything you publish; keep lightweight tags for local bookmarks.
Tag an Older Commit
Find the commit's hash and name it at the end:
git log --oneline -10
git tag -a v1.1.1 a1b2c3d -m "Release 1.1.1"List and Inspect Tags
| Command | What it shows |
|---|---|
git tag | All tags |
git tag -l "v1.2.*" | Tags matching a pattern |
git tag -n | Tags with their message |
git show v1.2.0 | Tag details and the commit |
git describe --tags | Nearest tag to HEAD |
By default, git tag sorts names as text, so v1.10.0 comes before v1.9.0. To sort by version number, newest first:
git tag --sort=-version:refnamePush Tags
git push origin v1.2.0This sends one tag. git push origin --tags sends every local tag, including private markers you may not want to publish. A tidier habit is to push commits and their annotated tags together:
git push --follow-tagsIt sends annotated tags that point at the commits being pushed, and skips lightweight ones. To make it the default, run git config --global push.followTags true. Pushing in general is covered in git push: upload commits to a remote.
Delete a Tag
git tag -d v1.2.0
git push origin --delete v1.2.0The first line deletes the tag in your clone, the second on the remote. Clones that already fetched the tag keep it until their owners delete it too.
Check Out a Tag
git switch --detach v1.2.0This puts your files at the tagged release without a branch, which is a detached HEAD; see Git detached HEAD. To fix something in an old release, start a branch from the tag instead:
git switch -c hotfix/1.2.1 v1.2.0Do Not Move a Published Tag
git tag -f can move a tag to another commit, but anyone who fetched the old one keeps it: Git does not change a tag that already exists in a clone behind its owner's back. Two people then build different code under the same version name. If a release was wrong, tag the fix as a new version, such as v1.2.1.
Signed Tags and Version Names
git tag -s creates an annotated tag signed with your GPG key, or your SSH key if Git is set up for SSH signing, and git tag -v checks the signature.
For names, most projects follow semantic versioning: MAJOR.MINOR.PATCH with a v in front. Raise the major number for incompatible changes, the minor number for new features, and the patch number for fixes. Pre-releases get a suffix, such as v2.0.0-rc.1. A tag is a ref like a branch, so it has the same naming limits as a branch, explained in how to create a branch in Git.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations