Git Tagging is used to mark specific points in a repository’s history as important. Tags are commonly used for releases such as v1.0 or milestones. Unlike branches, tags are fixed references and do not move.
A Git tag is a reference to a specific commit, often used to mark a particular point in a repository’s history such as a release version. Tags act like snapshots and are typically used for versioning code.
Tags can be created in two main forms:
// Create a lightweight tag on the current commit
git tag v1.0
// Create an annotated tag with a message
git tag -a v1.1 -m "First stable release"
// List all tags in the repository
git tag
// Show commit details associated with a tag
git show v1.0
// Push a specific tag to remote repository
git push origin v1.0
// Push all local tags to remote
git push --tags
// Delete a tag locally
git tag -d v1.0
// Delete a tag from remote repository
git push --delete origin v1.0
After tagging a commit, Git stores a permanent reference to that commit hash. When you push tags, collaborators can check out exactly the same version of code.
git show