Create a Git Tag and Push It to Remote
Mark a specific commit with a version tag and share it with your team via the remote repository.
When to use
Use tags to mark release points, version milestones, or any commit you want to reference easily later. Tags are commonly used for versioning (v1.0.0, v2.1.3) and deployment markers.
Pre-flight checklist
- Ensure you are on the correct branch and commit that you want to tag.
- Decide on a tag naming convention (semantic versioning like
v1.2.3is common). - Determine if you need a lightweight tag (just a pointer) or an annotated tag (includes metadata).
Steps
-
Check your current commit to confirm you are tagging the right point.
git log --oneline -5 -
Create an annotated tag with a message (recommended for releases).
git tag -a v1.0.0 -m "Release version 1.0.0" -
Or create a lightweight tag if you just need a simple marker.
git tag v1.0.0-beta -
Push the tag to the remote repository.
# Push a single tag git push origin v1.0.0 # Push all local tags at once git push origin --tags -
To tag an older commit, specify the commit hash.
git tag -a v0.9.0 -m "Retroactive tag for beta" abc1234
Verification
git taglists all local tags.git show v1.0.0displays the tag details and associated commit.- Check GitHub/GitLab releases page to confirm the tag appears remotely.
Managing tags
- Delete a local tag:
git tag -d v1.0.0 - Delete a remote tag:
git push origin --delete v1.0.0 - List tags matching a pattern:
git tag -l "v1.*" - Checkout a tagged version:
git checkout v1.0.0(detached HEAD)
Follow-up
- Create a GitHub Release from the tag for better visibility and release notes.
- Update your changelog or release documentation.
- Consider setting up CI/CD to automatically deploy when tags are pushed.