Lesson Completion
Back to course

Tagging Best Practices

Beginner
7 minutes4.7Git

The Hook (The "Byte-Sized" Intro)

A well-tagged repo tells its entire release history at a glance. A poorly-tagged repo has entries like test, final, really-final, and v1-fixed-again. Follow these 6 rules and your tags will be trustworthy, consistent, and useful for every part of the pipeline.

📖 What is Tagging Best Practices?

Guidelines for creating tags that are consistent, informative, and reliable across the team.

Conceptual Clarity

The 6 rules:

#RuleWhy
1Use annotated tags for releasesStores who, when, and why
2Follow SemVer namingv1.2.3 format is universally understood
3Tag only stable pointsTags should represent tested, deployable commits
4Always push tags explicitlyTags don't auto-push
5Never move release tagsTeams depend on tag immutability
6Use pre-release labelsv2.0.0-beta.1 clearly signals instability

Real-Life Analogy

Tags are like product version stamps on the packaging. If you stamp "v1.0" on an untested build, customers lose trust. If you keep changing what "v1.0" points to, nobody knows what they're running.

Visual Architecture

flowchart TD TAG["Creating a Tag"] --> ANNOTATED["✅ Annotated + Message"] TAG --> SEMVER["✅ SemVer Format"] TAG --> STABLE["✅ Tested and Stable"] TAG --> PUSH["✅ Push to Remote"] TAG --> IMMUTABLE["✅ Never Move After Push"] style ANNOTATED fill:#1b2d1b,stroke:#53d8fb,color:#53d8fb style SEMVER fill:#1b2d1b,stroke:#53d8fb,color:#53d8fb style STABLE fill:#1b2d1b,stroke:#53d8fb,color:#53d8fb style PUSH fill:#1b2d1b,stroke:#53d8fb,color:#53d8fb style IMMUTABLE fill:#1b2d1b,stroke:#53d8fb,color:#53d8fb

Why It Matters

  • Trust: Consistent tagging builds confidence in the release process.
  • Automation: CI/CD relies on predictable tag patterns to trigger deployments.
  • Debugging: Well-tagged repos make rollbacks instant and reliable.
  • Communication: Version numbers communicate intent across teams.

Code

bash
# ─── Good tagging workflow ─── # 1. Ensure all tests pass # 2. Create annotated tag with SemVer git tag -a v1.2.0 -m "Release: Add dark mode, fix #167" # 3. Push the tag git push origin v1.2.0 # ─── Configure auto-push for annotated tags ─── git config --global push.followTags true # ─── Pre-release tagging ─── git tag -a v2.0.0-rc.1 -m "Release candidate 1" git push origin v2.0.0-rc.1 # ─── Naming convention ─── # ✅ v1.0.0, v1.0.1, v2.0.0-beta.1 # ❌ release-1, final, test-tag, v1-fixed

Key Takeaways

  • Always use annotated tags with meaningful messages for releases.
  • Follow SemVer (v1.2.3) for consistent, understandable versioning.
  • Only tag tested, stable commits — never tag WIP or untested code.
  • Never move release tags after pushing — teams depend on their immutability.

Interview Prep

  • Q: Why should release tags be immutable? A: Teams, CI/CD pipelines, and deployment systems depend on tags pointing to specific commits. Moving a tag can cause confusion, re-trigger builds, break rollbacks, and erode trust in the release process.

  • Q: What naming convention should tags follow? A: Semantic Versioning prefixed with v: v1.0.0 for stable, v2.0.0-beta.1 for pre-release. This is universally understood and compatible with version sorting tools and CI/CD trigger patterns.

  • Q: Why should you only tag stable commits? A: Tags represent deployable milestones. Tagging untested code creates false confidence, can trigger production deployments of broken code, and makes rollback strategies unreliable.

Topics Covered

Git TagsGit Best Practices

Tags

#git#tags#best-practices#releases

Last Updated

2026-02-13