Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

Git Tutorial

Git HOME Git Intro Git Install Git Config Git Get Started Git New Files Git Staging Git Commit Git Remove and Move Git Tagging Git Stash Git History Git Diff Git Blame Git Help Git Branch Git Merge Git Workflow Git Best Practices

Git and GitHub

GitHub Get Started Git What is SSH? GitHub Add SSH GitHub Set Remote GitHub Edit Code Pull from GitHub Push to GitHub GitHub Branch Pull Branch from GitHub Push Branch to GitHub GitHub Flow GitHub Pages Git GUI Clients

Git Contribute

GitHub Fork Git Clone from GitHub GitHub Send Pull Request

Git Undo

Git Revert Git Reset Git Clean Git Amend Git Rebase Git Reflog Git Recovery

Git Advanced

Git .gitignore Git .gitattributes Git Large File Storage (LFS) Git Signing Commits/Tags Git Cherrypick & Patch Git Bisect Git Merge Conflicts Git CI/CD Git Hooks Git Submodules Git Worktree Git Remote Advanced

Git and Bitbucket

Bitbucket Get Started Bitbucket Add SSH Bitbucket Set Remote Bitbucket Edit Code Bitbucket Branch Bitbucket Pages Bitbucket Fork Git Clone from Bitbucket Bitbucket Send Pull Request

Git and GitLab

GitLab Get Started GitLab Add SSH GitLab Set Remote GitLab Edit Code GitLab Branch GitLab Pages GitLab Fork Git Clone from GitLab GitLab Send Pull Request

Git Cert

Git Certificate

Git Reference

Git Glossary

Git Exercises

Git Terminal Git Exercises Git Challenges Git Quiz Git Syllabus Git Study Plan

Git Tagging


Share

Key Commands for Tagging

  • git tag <tagname> - Create a lightweight tag
  • git tag -a <tagname> -m "message" - Create an annotated tag
  • git tag <tagname> <commit-hash> - Tag a specific commit
  • git tag - List tags
  • git show <tagname> - Show tag details

What is a Tag?

A 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:

  • Releases: Tags let you mark when your project is ready for release, so you (and others) can always find that exact version later.
  • Milestones: Use tags to highlight major milestones, like when a big feature is finished or a bug is fixed.
  • Deployment: Many deployment tools use tags to know which version of your code to deploy.
  • Hotfixes: If you need to fix an old version, tags make it easy to check out and patch the right code.

Create a Lightweight Tag

A lightweight tag is just a name for a commit.

It's quick and simple, but does not store extra information.

Annotated vs Lightweight Tags

  • 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
Try it Yourself »


Create an Annotated Tag (-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"
Try it Yourself »

Tag a Specific Commit

You can tag an older commit by specifying its hash:

Example

git tag v1.1 1a2b3c4d
Try it Yourself »

Replace 1a2b3c4d with the commit hash you want to tag.


List Tags

See all tags in your repository:

Example

git tag
v1.0
v1.1
Try it Yourself »

Show Tag Details (git show)

See details about a tag and the commit it points to:

Example

git show v1.0
tag v1.0
Tagger: W3Schools &lt;test@w3schools.com&gt;
Date:   Wed Jan 15 10:00:00 2025 +0000

Version 1.0 release

commit b2df4898431ad30d09715695283a80e01b22c2dc (HEAD -&gt; main, tag: v1.0)
Author: W3Schools &lt;test@w3schools.com&gt;
Date:   Wed Jan 15 10:00:00 2025 +0000

    Add a new line

diff --git a/index.html b/index.html
index 597ecf5..c57442b 100644
--- a/index.html
+++ b/index.html
@@ -1 +1,2 @@
 &lt;h1&gt;Hello world!&lt;/h1&gt;
+&lt;p&gt;A new line in our file!&lt;/p&gt;
Try it Yourself »

Push Tags to Remote

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
Try it Yourself »

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
Try it Yourself »

Delete Tags

Delete a tag locally:

Example

git tag -d v1.0
Deleted tag 'v1.0' (was b2df489)
Try it Yourself »

Delete a tag from the remote repository:

Example

git push origin --delete tag v1.0
Try it Yourself »

Update or Replace a Tag (Force Push)

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
Try it Yourself »

Tagging Best Practices

  • Use tags to mark releases, major milestones, or stable points in your project.
  • Always use annotated tags (with -a -m) for anything public or shared.
  • Create tags after passing all tests or before deploying/releasing code.

Troubleshooting

  • Tag already exists? Use git tag -d <tagname> to delete it, then re-create.
  • Pushed the wrong tag? Delete it locally and remotely, then push the correct tag.
  • Tag not showing on remote? Remember to push tags with git push origin <tagname> or git push --tags.
  • Need to overwrite a tag on the remote? You can force-push a tag with git push --force origin <tagname>, but be careful! This will overwrite the tag for everyone using the remote.



Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.