Git Tagging provides essential version control capabilities for managing codebase changes cleanly, predictably, and efficiently.
git tag <tagname> - Create a lightweight taggit tag -a <tagname> -m "message" - Create an annotated taggit tag <tagname> <commit-hash> - Tag a specific commitgit tag - List tagsgit show <tagname> - Show tag detailsA tag in Git is like a label or bookmark for a specific commit.
Tags are most often used to mark important points in your project history, like releases (v1.0 or v2.0).
Tags are a simple and reliable way to keep track of versions and share them with your team or users.
Some common tag types include:
A lightweight tag is just a name for a commit.
It's quick and simple, but does not store extra information.
Annotated Tag: Stores author, date, and message.
Recommended for releases and sharing with others.
Lightweight Tag: Just a simple name for a commit (no extra info, like a bookmark).
Example
git tag v1.0
-a -m)An annotated tag stores your name, the date, and a message.
This is recommended for most uses.
Example
git tag -a v1.0 -m "Version 1.0 release"
You can tag an older commit by specifying its hash:
Example
git tag v1.1 1a2b3c4d
Replace 1a2b3c4d with the commit hash you want to tag.
See all tags in your repository:
Example
git tag
git show)See details about a tag and the commit it points to:
Example
git show v1.0
By default, tags exist only on your local computer.
If you want others to see your tags, you need to push them to your remote repository.
If you don't push your tags, only you will see them, and only locally.
To push a single tag to your remote repository (for example, after creating a release tag):
Example: Push a Single Tag
git push origin v1.0
Did you know? Pushing commits with git push does not push your tags!
You must push tags explicitly as shown above.
To push all your local tags to the remote at once (useful if you've created several tags):
Example: Push All Tags
git push --tags
Delete a tag locally:
Example
git tag -d v1.0
Delete a tag from the remote repository:
Example
git push origin --delete tag v1.0
If you need to move a tag to a different commit and update the remote, use --force:
Example
git tag -f v1.0 <new-commit-hash>
git push --force origin v1.0
-a -m) for anything public or shared.git tag -d <tagname> to delete it, then re-create.git push origin <tagname> or git push --tags.git push --force origin <tagname>, but be careful! This will overwrite the tag for everyone using the remote.Execute the following terminal commands to work with this concept in your workspace:
# Check repository status
git status
# View formatted log
git log --oneline -n 5
Fix CORS bug rather than Fixed CORS bug).git diff to review unstaged modifications before adding files to the index.git switch -c <branch-name> to preserve edits.git restore --staged <filename> to remove the file from the index without altering your local workspace copy.Open your terminal in a test project directory, execute git status, and verify your current working tree state. Practice running git log --oneline to review commit history.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With