What is Git Tag?
Git tag is used to mark a specific point in your Git history, usually to represent a version, release, or important milestone in your project.
For example, when you release version v1.0 of your application, you can create a tag:
git tag v1.0This acts like a permanent reference to that exact state of your code.
In simple terms:
Git tag = label for a specific commit (used for versions/releases)
Why do we use Git tags?
Git tags are mainly used to:
- Mark release versions (e.g., v1.0, v2.0)
- Track important milestones in development
- Easily reference stable versions of code
- Simplify deployments and CI/CD workflows
Instead of remembering commit hashes, you can use readable names like v1.0.
Tags are widely used in workflows explained in git workflow, especially for release management.
What does git tag do?
When you create a tag:
- It points to a specific commit
- It does not change automatically (unlike branches)
- It helps you revisit that exact version anytime
Tags are static references, while branches move forward with new commits.
What is tagging in Git?
Tagging in Git means assigning a name (tag) to a specific commit.
There are two types of tags:
- Lightweight tag → simple reference
- Annotated tag → includes metadata (author, message, date)
Annotated tags are recommended for releases because they provide more context.
Git Tag – Quick Cheat Sheet
| Description | Command |
|---|---|
| Create lightweight tag | git tag <tag> |
| Create annotated tag | git tag -a <tag> -m "message" |
| Create tag for specific commit | git tag <tag> <commit> |
| Create version tag | git tag v1.0.0 |
| List all tags | git tag |
| List tags with pattern | git tag -l "v1.*" |
| Show tag details | git show <tag> |
| Show tag commit | git show <tag> |
| Push single tag | git push origin <tag> |
| Push all tags | git push origin --tags |
| Fetch tags from remote | git fetch --tags |
| Delete local tag | git tag -d <tag> |
| Delete remote tag | git push origin --delete <tag> |
| Update/move tag | delete + recreate |
| Force update tag | git tag -f <tag> |
| Checkout tag | git checkout tags/<tag> |
| Create branch from tag | git checkout -b <branch> <tag> |
| Tag current HEAD | git tag <tag> |
| Tag previous commit | git tag <tag> HEAD~1 |
| Verify tag (GPG) | git tag -v <tag> |
| Create signed tag | git tag -s <tag> |
| Rename tag | delete + recreate |
| Sort tags | git tag --sort=version:refname |
| List latest tag | git describe --tags |
| Push specific tag with force | git push -f origin <tag> |
| Delete all local tags | git tag -l | xargs git tag -d |
| Check tag history | git log --tags |
| Tag after commit | git tag <tag> |
| Add tag to commit | git tag <tag> <commit> |
Quick Examples
# Create annotated tag
git tag -a v1.0 -m "First release"
# Push tag
git push origin v1.0
# List tags
git tag
# Checkout tag
git checkout tags/v1.0
# Delete tag
git tag -d v1.0Create Git Tag
Create lightweight tag
A lightweight tag is the simplest way to mark a commit in Git. It acts as a pointer to the current commit without storing additional metadata.
git tag v1.0This is useful for quickly marking versions or milestones during development.
Before creating tags, ensure your repository is properly initialized using git init tutorial.
Create annotated tag
Annotated tags are recommended for releases because they include metadata such as author, date, and message.
git tag -a v1.0 -m "First stable release"These tags provide better context and are commonly used in production workflows. Writing meaningful messages here follows the same best practices as git commit message.
Create tag for specific commit
You can create a tag for any past commit using its hash:
git tag v1.1 <commit-hash>To find the commit hash, you can use:
git log --onelineUnderstanding commit references like HEAD~1 or hashes is explained in
git head caret vs tilde examples.
List and View Tags
List all tags in Git
To view all tags in your repository:
git tagThis lists all tags, helping you track versions and milestones.
Filter tags by pattern
You can filter tags using patterns:
git tag -l "v1.*"This is useful when working with version-based tagging (e.g., semantic versioning like v1.0, v1.1).
Show tag details
To view detailed information about a tag:
git show v1.0This displays:
- commit message
- author
- changes introduced
This is similar to inspecting commits using git show command, but focused on tagged versions.
Push and Share Tags
Push single tag to remote
After creating a tag locally, you need to push it to the remote repository:
git push origin v1.0This shares the tag with your team so everyone can access the same version.
For general push behavior, refer to git push examples.
Push all tags
To push all local tags at once:
git push origin --tagsThis is useful when you have created multiple tags and want to sync them with the remote repository.
Fetch tags from remote
To download tags from the remote repository:
git fetch --tagsThis ensures your local repository is updated with all tags created by others. Learn more about fetching in git fetch examples.
Manage Tags (Update, Delete, Move)
Delete local and remote tag
To delete a local tag:
git tag -d v1.0To delete a remote tag:
git push origin --delete v1.0This helps keep your repository clean by removing outdated or incorrect tags.
Move or update tag
Git tags are meant to be immutable, but you can update them if needed.
To move a tag:
git tag -f v1.0 <commit-hash>Then push the updated tag:
git push -f origin v1.0Rename tag
Git does not support renaming directly. Instead:
git tag -d old-tag
git tag new-tagThen push changes:
git push origin --delete old-tag
git push origin new-tagThis approach ensures consistency across local and remote repositories.
Checkout and Use Tags
Checkout tag in Git
To view code at a specific tag:
git checkout tags/v1.0This puts your repository into a detached HEAD state.
Learn more about this state in git detached head examples.
Create branch from tag
To start development from a tagged version:
git checkout -b feature-v1 v1.0This is useful when you want to fix bugs or build features based on a stable release. Branch workflows are explained in git branch examples.
Difference between tag vs branch
- Tag → fixed reference to a specific commit
- Branch → moving pointer that updates with new commits
Use tags for:
- releases
- versioning
Use branches for:
- feature development
- ongoing work
To understand this better, refer to git merge vs rebase for how branches evolve over time.
Fix Common Errors
tag already exists
This error occurs when you try to create a tag with a name that already exists:
fatal: tag 'v1.0' already existsFix options:
- Use a different tag name
- Delete the existing tag and recreate it
git tag -d v1.0
git tag v1.0If the tag exists on remote, delete it there as well before recreating.
tag not pushed
By default, tags are not pushed automatically when you push commits.
Fix:
Push a specific tag:
git push origin v1.0Or push all tags:
git push origin --tagsThis is a common confusion since normal git push only pushes branches. Learn more about push behavior in
git push examples.
cannot checkout tag
This error can happen due to:
- Incorrect tag name
- Tag not fetched from remote
- Detached HEAD confusion
Fix:
git fetch --tags
git checkout tags/v1.0When you checkout a tag, Git enters a detached HEAD state. To continue development, create a branch:
git checkout -b new-branch v1.0Learn more about this behavior in git detached head examples.
Frequently Asked Questions
1. What is git tag?
Git tag is used to mark a specific commit in Git history, usually to represent a version or release of a project.2. How do I create a tag in Git?
You can create a tag usinggit tag <tag> for a lightweight tag or git tag -a <tag> -m "message" for an annotated tag.3. How do I push tags to remote?
You can push a tag usinggit push origin <tag> or push all tags using git push origin --tags.4. How do I delete a Git tag?
You can delete a local tag usinggit tag -d <tag> and a remote tag using git push origin --delete <tag>.5. What is the difference between tag and branch in Git?
A tag is a fixed reference to a commit, while a branch is a moving pointer that updates with new commits.Summary
Git tags are essential for marking versions and important milestones in your project.
In this guide, you learned how to:
- Create lightweight and annotated tags
- List and inspect tags
- Push and share tags with remote repositories
- Manage tags (delete, update, move)
- Use tags for versioning and releases
- Fix common tagging errors
Using Git tags effectively helps maintain clear version history, improves collaboration, and simplifies release management.



![Git Error: Cannot Delete Branch Checked Out or Used by Worktree [SOLVED]](/cannot-delete-branch-checked-out-at/git-cannot-delete-branch_hu_3f86bd25a59d627d.webp)






