Git Tag
In short
A Git tag is a named, permanent pointer to a specific commit, most often used to mark release versions such as v1.0.0 in a repository's history.
What is a Git tag?
A Git tag is a human-readable label attached to one specific commit. Unlike a branch, which moves forward every time you commit, a tag stays on the same commit unless someone deliberately deletes or moves it. Teams mainly use tags to mark releases, so anyone can find exactly which code shipped as version v2.3.0.
Git has two kinds of tags. A lightweight tag is just a name pointing at a commit, like a bookmark. An annotated tag, created with git tag -a, is stored as a full Git object that includes the tagger's name, a date, a message, and optionally a cryptographic signature, which is why annotated tags are recommended for releases. Tags are not pushed by default, so you must send them explicitly with git push origin v2.3.0 or git push --tags.
Think of a tag like a sticky note in a book's revision history that says 'this is the edition we printed'. Tags usually follow semantic versioning, such as v1.4.2, and CI/CD pipelines often watch for new tags to build and publish a release automatically. Code hosting platforms also use tags as the basis for release pages and downloadable source archives.
The most common confusion is tag versus branch. A branch is a movable pointer meant for ongoing work, while a tag is a fixed pointer meant to record a moment in history. If you check out a tag directly, Git puts you in a detached HEAD state, which means new commits won't belong to any branch unless you create one.
Key takeaways
- A tag is a fixed, named pointer to a single commit.
- Annotated tags store an author, date, and message and are recommended for releases.
- Lightweight tags are simple name-to-commit pointers with no extra data.
- Tags must be pushed explicitly; a plain
git pushdoes not send them. - Unlike branches, tags do not move when new commits are added.
Example
# Create an annotated tag for a release on the current commit
git tag -a v1.2.0 -m "Release 1.2.0"
# List tags and show the details of one
git tag
git show v1.2.0
# Tags are not pushed automatically
git push origin v1.2.0
# Delete a tag locally and on the remote
git tag -d v1.2.0
git push origin --delete v1.2.0Readers ask
What is the difference between a Git tag and a branch?
A branch is a pointer that moves forward as you add commits, while a tag stays attached to one commit permanently. Branches are for ongoing work; tags mark fixed points such as releases.
Should I use annotated or lightweight tags?
Use annotated tags for releases and anything you share, because they record who created the tag, when, and why, and they can be signed. Lightweight tags are fine for temporary, private bookmarks.
How do I push tags to a remote?
Push a single tag with git push origin <tagname>, or push all local tags with git push --tags. You can also use git push --follow-tags to push commits together with the annotated tags that point to them.
See also
- CommitVersion Control, p. 5A commit is a saved snapshot of a project's files in Git, recorded with a unique ID, an author, a timestamp, and a message describing what changed.
- Semantic VersioningVersion Control, p. 35Semantic versioning is a MAJOR.MINOR.PATCH numbering scheme in which each part signals whether a release breaks compatibility, adds features, or fixes bugs.
- BranchVersion Control, p. 2A branch in Git is an independent line of development that lets you work on a feature or fix in isolation, without affecting the main code until you merge it.
- GitVersion Control, p. 10Git is a free, open-source distributed version control system that tracks changes to files over time, so developers can collaborate and undo mistakes.
- CI/CDDevOps & Cloud, p. 9CI/CD is a set of automated practices that build, test, and release code changes frequently, so software can be delivered to users quickly and safely.
- RepositoryVersion Control, p. 34A repository is the storage location for a project, holding all of its files plus the complete history of every change recorded by a version control system.
Spotted a mistake or something missing on this page?Suggest an edit