Git tags Command
In this page:
Creating Lightweight Tags
A lightweight tag is just a named pointer to a specific commit, with no extra metadata of its own — essentially a branch that never moves. They're quick to create and fine for private, temporary bookmarks, but they lack the authorship and message info that a real release usually wants.
Example: Creating Lightweight Tags
git tag v1.0
Creating Annotated Tags
An annotated tag (git tag -a v1.0 -m "message") is stored as a full object in Git's database, complete with the tagger's name, email, date, and a message — the same way a commit is. This is the recommended tag type for anything you'll actually publish as a release, since the extra metadata documents who cut the release and why.
Example: Creating Annotated Tags
git tag -a v1.0 -m "Release version 1.0"
Listing and Searching Tags
git tag alone lists every tag in the repository, and git tag -l "v1.*" filters that list to a glob pattern — handy once a project has accumulated dozens of version tags and you only care about one release line.
Example: Listing and Searching Tags
git tag
git tag -l "v1.*"
Deleting Project Tags
git tag -d <name> deletes a tag locally, but since tags are pushed to a remote separately from commits, you also need git push origin --delete <name> (or :refs/tags/<name>) to remove it from the shared remote — otherwise it just reappears the next time someone fetches.
Example: Deleting Project Tags
git tag -d v1.0
git push origin --delete v1.0
Sharing Tags on Remote Servers
Unlike commits and branches, git push does not upload tags by default, so a tag you create locally is invisible to collaborators until you explicitly push it with git push origin <tagname> or push all tags at once with git push --tags.
Example: Sharing Tags on Remote Servers
git push origin v1.0
git push origin --tags
Chapter Quiz — Complete all 18 topics to unlock
0/18 topics done
Complete these topics first:
- Git init Command
- Git New Files
- Git Staging Environment
- Git clone Command
- Git status Command
- Git help Command
- Git add Command
- Git commit Command
- Git tags Command
- Git stash Command
- Git log Command
- Git diff Command
- Git show Command
- Git rm Command
- Git mv Command
- Git restore Command
- Git clean Command
- Git ignore (.gitignore)