A Git tag is a reference that points to a specific commit in a Git repository. Tags are commonly used to mark important points in project history, such as software releases, versions, and milestones.
v1.0.0, v2.0.0, or
release-2026.
A Git tag is a named reference to a specific commit.
v1.0.0 → Commit A
Instead of remembering a long commit hash, you can use a meaningful tag name to identify an important version.
Tags are commonly used to mark important versions or milestones.
Suppose a project reaches its first stable release:
v1.0.0
You can create a tag named v1.0.0 pointing to the
corresponding commit.
git tag v1.0.0
A simple tag can be created with:
git tag v1.0.0
This creates a lightweight tag that points directly to the current commit.
Use the following command to list tags:
git tag
Example:
v1.0.0
v1.1.0
v2.0.0
An annotated tag stores additional information such as the tagger, date, message, and tag object.
git tag -a v1.0.0 -m "First stable release"
Annotated tags are commonly useful for release points.
| Lightweight Tag | Annotated Tag |
|---|---|
| Simple reference | Full tag object |
| Points directly to a commit | Stores tag information |
git tag v1.0.0 |
git tag -a v1.0.0 -m "Release" |
You can create a tag for a specific commit instead of the current commit.
git tag v1.0.0 8f32abc
Here, 8f32abc represents the commit that should receive
the tag.
You can also create an annotated tag on a specific commit:
git tag -a v1.0.0 8f32abc -m "First stable release"
Use git show to inspect a tag:
git show v1.0.0
For an annotated tag, Git can show the tag information and the associated commit details.
You can filter tags using a pattern:
git tag -l "v1.*"
This can display tags that begin with v1..
Many software projects use version formats such as:
v1.0.0
v1.1.0
v1.2.0
v2.0.0
This style is commonly associated with semantic versioning.
After completing a stable version of an application, you can create a release tag:
git tag -a v1.0.0 -m "Release version 1.0.0"
The tag provides a convenient reference to that release point.
Tags are not automatically pushed to a remote repository by a normal
git push in the same way as ordinary branch updates.
You can explicitly push a tag:
git push origin v1.0.0
To push all local tags to a remote:
git push origin --tags
This sends local tags that are not already present on the remote.
To delete a tag from your local repository:
git tag -d v1.0.0
This removes the local tag reference.
To delete a tag from a remote repository:
git push origin --delete v1.0.0
This removes the specified tag from the remote repository.
You can inspect the project at a tagged commit:
git switch --detach v1.0.0
This checks out the tagged commit in a detached HEAD state.
When you switch directly to a tag, HEAD is normally detached from a branch.
HEAD → v1.0.0 → Commit
You can inspect or test that version without moving a branch pointer.
If you want to continue development from a tagged version, create a new branch:
git switch -c maintenance-v1 v1.0.0
This creates a new branch starting at the commit referenced by the tag.
You can inspect which tags point to a particular commit using:
git tag --points-at 8f32abc
This is useful when you want to identify tags associated with a specific commit.
When tags are pushed to GitHub, they can be used to identify specific versions of a project and can also be associated with GitHub releases.
git push origin v1.0.0
The tag remains a Git reference pointing to a specific commit.
git add .
git commit -m "Complete payment module"
git tag -a v2.0.0 -m "Payment module release"
The tag is created at the current commit.
You can list tags along with their messages:
git tag -n
Example:
v1.0.0 First stable release
v1.1.0 Add user dashboard
v2.0.0 Major application update
Git can sort tags using version-aware sorting:
git tag --sort=version:refname
This can be useful when a project has many version tags.
git tag
git tag v1.0.0
git tag -a v1.0.0 -m "Release 1.0.0"
git tag -l "v1.*"
git tag -n
git show v1.0.0
git tag -d v1.0.0
git push origin v1.0.0
git push origin --tags
git push origin --delete v1.0.0
# Check status
git status
# View recent commits
git log --oneline
# Create annotated tag
git tag -a v1.0.0 -m "First stable release"
# View the tag
git show v1.0.0
# Push the tag
git push origin v1.0.0
# Verify local tags
git tag
git init
git add .
git commit -m "Initial project"
git tag -a v1.0.0 -m "Initial stable release"
git tag
git show v1.0.0
git push origin v1.0.0
The project now has a named release point that refers to the commit containing the initial stable version.
Git tags provide meaningful names for important commits. They are commonly used for software releases and project milestones.
git tag v1.0.0git tag -a v1.0.0 -m "Release 1.0.0"Tags can be listed, inspected, pushed to remote repositories, deleted, and used to inspect a specific version of a project.
git tag v1.0.0 creates a lightweight tag.git tag -a creates an annotated tag.git tag lists local tags.git show v1.0.0 displays information about a tag.git tag -d deletes a local tag.git push origin v1.0.0 pushes a specific tag.git push origin --tags pushes local tags to the remote.git push origin --delete deletes a remote tag.Question: What is a Git tag mainly used for?