Module 6 Lesson 5: Tagging and releases
·DevOps

Module 6 Lesson 5: Tagging and releases

Mark your milestones. Learn how to use 'git tag' to label specific points in history as important releases, and discover the difference between lightweight and annotated tags.

Module 6 Lesson 5: Tagging and releases

In a large project, history can have thousands of commits. How do you find the exact commit that corresponds to "Version 1.0"?

You could search for a commit message, or you could use a Tag. A tag is a persistent, human-readable label that points to a specific commit. Unlike a branch, a tag does not move. It stays fixed at that specific commit forever.


1. Types of Tags

Git supports two types of tags:

Lightweight Tags

This is just a pointer to a commit. It’s like a bookmark.

git tag v1.0-beta

Annotated Tags (Recommended)

These are stored as full objects in the Git database. They contain the tagger name, email, date, and a tagging message.

  • Use case: Official releases.
git tag -a v1.2.0 -m "Release version 1.2.0"

2. Listing and Searching Tags

Shows all tags in alphabetical order:

git tag

Search for tags that match a pattern:

git tag -l "v1.*"

3. Sharing Your Tags

By default, the git push command doesn't send tags to remote servers. You have to explicitly push them:

# Push a specific tag
git push origin v1.2.0

# Push ALL your tags at once
git push origin --tags

Once pushed, services like GitHub will automatically create a "Release" for those tags, allowing users to download .zip files of the project at that specific version.


4. Tagging Old Commits

Did you forget to tag a release? You can tag a commit from the past by providing its ID:

git tag -a v1.0.0 9fceb02

Module 6 Advanced Features Practice Exercises

It’s time to test your expert Git skills:

  1. Stashing: Make a change, stash it, then list your stashes to verify it's there.
  2. Cherry-pick: Create a new branch fix-branch, make a commit called "The important fix", and then cherry-pick just that commit into main.
  3. Interactive Rebase: Make 3 small commits on a branch, then use git rebase -i to squash them into one single commit with a descriptive message.
  4. Tagging: Annotate your final squashed commit with the tag v1.0.0-practice.
  5. Verification: Run git log --oneline --graph --decorate. You should see your commit history looking clean, with your tag clearly pointing to the top commit!

Checkpoint: If you successfully performed a squash and a tag, you have officially moved beyond "Basic Git" into the "Advanced User" category!


Summary

In this lesson, we established:

  • Tags are fixed markers for important milestones (like versions).
  • Annotated tags (-a) are preferred for official releases.
  • Tags must be pushed separately using --tags.
  • git log --decorate shows you exactly where your tags and branch pointers are in history.

Module Complete! You have mastered the most powerful features of the Git CLI.

Next Module: We’ll move into the world of "Project Architecture." Welcome to Module 7: Git Submodules, where we’ll learn how to handle repositories inside other repositories.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn