Lesson

Git Tagging

10 min reading
Free Course

Git Tagging: Marking Release Versions in History

A Git tag attaches a permanent, human-readable label such as v1.0.0 or v2.1.3 to a specific commit. Teams use tags to mark production releases, deployment checkpoints, and hotfix milestones without creating extra branches.

Annotated vs Lightweight Tags

Git supports two tag types, and choosing the right one matters for shared projects:

Tag Type Command Stores Author, Date & Message Best Used For
Annotated git tag -a v1.0.0 -m "..." Yes (full Git object) Public releases and CI/CD builds
Lightweight git tag temp-check No (just a commit pointer) Temporary local bookmarks

Create an annotated tag for releases so teammates know who created the release and why:

git tag -a v1.0.0 -m "Release initial homepage and styles.css"

Listing, Inspecting, and Tagging Past Commits

List all tags alphabetically or filter them by pattern:

git tag
git tag -l "v1.*"

Inspect tag metadata and the target commit diff with git show v1.0.0. If you forgot to tag a release before making newer commits, pass the commit hash at the end of the command:

git tag -a v0.9.0 9fceb02 -m "Tag beta release commit"

Pushing and Deleting Tags

git push does not upload tags automatically. Push a single release tag or all local tags explicitly:

git push origin v1.0.0
git push origin --tags

To remove a local tag or delete an accidental tag from the remote repository:

git tag -d v1.0.0
git push origin --delete v1.0.0

Common Tagging Mistakes

Unlike branches, tags are meant to stay pinned to one commit forever. Moving an existing public tag with git tag -f breaks local clones for teammates because Git does not overwrite already-fetched tags automatically. Create a patch tag like v1.0.1 instead.

Frequently Asked Questions

How do I check out the code at a specific tag?

Run git switch --detach v1.0.0 (or git checkout v1.0.0) to inspect the exact files from that release. Create a hotfix branch with git switch -c hotfix/v1.0.1 before committing changes.

Why did git push not send my new tag to GitHub?

Git separates branch pushes from tag pushes by design so local personal tags never leak onto shared remotes. Always run git push origin <tag-name> when publishing a release.

Should I use v1.0.0 or 1.0.0 as my tag format?

Follow Semantic Versioning (MAJOR.MINOR.PATCH). Adding a lowercase v prefix like v1.0.0 is widely supported by GitHub Releases, npm, Composer, and Go modules.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol
Git Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum