DevOpsLesson
DevOpsLesson

Free, comprehensive DevOps tutorials and learning roadmaps. Master Docker, Kubernetes, CI/CD, and more.

Stay Updated

Get notified about new tutorials and features.

Tutorials

  • What is DevOps?
  • Docker Tutorial
  • Terraform Tutorial
  • CI/CD Pipeline
  • All Tutorials

Roadmaps

  • DevOps Engineer
  • Cloud Engineer
  • SRE Path
  • All Roadmaps

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 DevOpsLesson. All rights reserved.

DOCKERKUBERNETESTERRAFORMAWSCI/CDLINUXGITDEVOPS ROADMAPCLOUD ROADMAPSRE ROADMAPGIT CHEATSHEETDOCKER CHEATSHEETK8S CHEATSHEETTF CHEATSHEETLINUX CHEATSHEETDOCKERFILE LINTERYAML VALIDATORCRON PARSERREGEX TESTER

Git Tutorial

Introduction to Git
Installing Git
Git Basics
Git Branching
Git Merging
Git Rebasing
Git Remote
Git Stash
Undoing Changes in Git
Git Tagging
GitHub Workflow with Git
Advanced Git
Git Hooks
Git Workflows
Git Aliases and Configuration
Git Submodules
Git Commit Messages

Git Tagging

PreviousPrev
Next

Learn how Git tags work, including annotated and lightweight tags, pushing tags, deleting tags, and checking out a tag.

What a Tag Is

A tag is a named reference to a specific commit. Teams often use tags to mark releases such as v1.0.0, v1.1.0, or prod-2026-07-14.

Unlike branches, tags normally do not move. They point to an exact moment in history.

Tip: Use tags to mark important milestones such as production releases, stable demos, or compliance snapshots.

Lightweight vs Annotated Tags

Git supports two common tag types.

Lightweight Tag

A lightweight tag is just a simple name pointing to a commit.

git tag v1.0.0

This is quick and useful for personal or temporary markers.

Annotated Tag

An annotated tag stores extra metadata such as the tagger name, date, and message.

git tag -a v1.0.0 -m "Release version 1.0.0"

Annotated tags are generally better for official releases.

Listing Tags

To list all tags:

git tag

To filter by a pattern:

git tag -l "v1.*"

This is useful when a repository has many releases.

Tagging Older Commits

You do not have to tag only the latest commit. First find the commit ID:

git log --oneline

Then tag that specific commit:

git tag -a v0.9.0 a1b2c3d -m "Backfill tag for pre-release"

This is common when teams forget to tag a release at the time it happened.

Pushing Tags to a Remote

Tags do not automatically go to the remote when you push a branch.

Push one tag:

git push origin v1.0.0

Push all tags:

git push origin --tags

If your deployment pipeline uses tags as release triggers, this step is essential.

Deleting Tags

Delete a local tag:

git tag -d v1.0.0

Delete a remote tag:

git push origin --delete v1.0.0

Be careful when removing release tags because other systems or teammates may rely on them.

Checking Out a Tag

You can inspect the repository at a tagged release:

git checkout v1.0.0

This usually places you in detached HEAD state because you are on a commit, not a branch.

If you want to make changes starting from that tag, create a branch:

git switch -c hotfix-from-v1.0.0

Note: Checking out a tag is excellent for reproducing a past release, testing an older version, or debugging a regression.

Release Example

A simple release workflow could look like this:

git switch main
git pull
git tag -a v2.0.0 -m "Release version 2.0.0"
git push origin main
git push origin v2.0.0

Now the code and the release marker are both available remotely.

When to Use Each Tag Type

Use lightweight tags when:

  • you need a quick local marker
  • the tag is informal or temporary

Use annotated tags when:

  • the tag represents a real release
  • you want metadata and a message
  • the tag will be shared with the team

What You Should Remember

Tags mark important commits. Lightweight tags are simple pointers, while annotated tags carry release-friendly metadata. Tags are not pushed automatically, so remember to send them to the remote when needed. When checking out a tag, be aware of detached HEAD and create a branch if you plan to continue working.

For real release workflows, annotated tags are usually the better choice.

Test Your Understanding

Let's see how well you understood the concepts! These exercises will help reinforce what you just learned.

Exercise 1: Picking the right release marker

Scenario: Your team is creating an official v2.0.0 release and wants tag metadata plus a message.

Question: Which kind of tag from the tutorial is the better fit?

Exercise

Exercise 1: Picking the right release marker

Choose the tag type that stores release-friendly metadata and a message.

Exercise 2: Publishing the release tag

Scenario: You created v2.0.0 locally and your deployment pipeline watches for tags on the remote.

Question: What important step from the lesson must you remember?

Exercise

Exercise 2: Publishing the release tag

Identify the extra action needed because tags are not pushed automatically with branch pushes.

Exercise 3: Working from a tag

Scenario: You checked out v1.0.0 to investigate an older release and now need to make a hotfix based on that state.

Question: What is the safest next step from the tutorial?

Exercise

Exercise 3: Working from a tag

Choose the action that avoids staying in detached HEAD when continuing work from a tag.

PreviousPrev
Next

Continue Learning

Git Remote

Learn how Git remotes work, including add, remove, fetch, pull, push, tracking branches, and upstream configuration.

15 min·Easy

Git Stash

Learn how to temporarily save unfinished work with stash, including apply, pop, drop, list, named stashes, and untracked files.

12 min·Easy

Undoing Changes in Git

Learn how to use restore, reset, revert, and clean safely, and understand the difference between undoing local work and undoing shared history.

18 min·Medium

Explore Related Topics

CI

CI/CD Tutorials

Trigger automated pipelines from Git workflows

Li

Linux Tutorials

Use Git effectively on the Linux command line

On This Page

What a Tag IsLightweight vs Annotated TagsLightweight TagAnnotated TagListing TagsTagging Older CommitsPushing Tags to a RemoteDeleting TagsChecking Out a TagRelease ExampleWhen to Use Each Tag TypeWhat You Should RememberTest Your UnderstandingExercise 1: Picking the right release markerExercise 2: Publishing the release tagExercise 3: Working from a tag