SovranCode
HomeCourses Git & GitHub Git Tags
This device
Course contentsGit Tags · 41 topics

1. Git Fundamentals

Git IntroductionGit Version ControlGit vs GitHubGit InstallationGit Working TreeGit RepositoryGit CommitGit .gitignoreGit Project: Learning Journal

2. Git History

Git LogGit DiffGit ResetGit RevertGit StashGit Project: Messy Repository

3. Branches & History

Git BranchGit MergeGit Merge ConflictsGit RebaseGit Cherry-PickGit TagsGit Project: Feature Branch

4. Remotes and GitHub

Git RemoteGitHub AuthenticationGitHub RepositoryGitHub ForkGitHub IssuesGitHub PagesGit Project: Two Clone Sync

5. GitHub Collaboration

GitHub Pull RequestsGitHub Code ReviewGit Branching WorkflowGitHub Branch ProtectionGitHub CollaborationGitHub ContributingGit Project: Reviewed Pull Request

6. Automation and Professional Git

GitHub ActionsGit InternalsGit RecoveryGitHub SecurityGit Project: Team Repository CIProject
Learn Git & GitHub40 complete · 1 planned

1. Git Fundamentals

Git IntroductionGit Version ControlGit vs GitHubGit InstallationGit Working TreeGit RepositoryGit CommitGit .gitignoreGit Project: Learning Journal

2. Git History

Git LogGit DiffGit ResetGit RevertGit StashGit Project: Messy Repository

3. Branches & History

Git BranchGit MergeGit Merge ConflictsGit RebaseGit Cherry-PickGit TagsGit Project: Feature Branch

4. Remotes and GitHub

Git RemoteGitHub AuthenticationGitHub RepositoryGitHub ForkGitHub IssuesGitHub PagesGit Project: Two Clone Sync

5. GitHub Collaboration

GitHub Pull RequestsGitHub Code ReviewGit Branching WorkflowGitHub Branch ProtectionGitHub CollaborationGitHub ContributingGit Project: Reviewed Pull Request

6. Automation and Professional Git

GitHub ActionsGit InternalsGit RecoveryGitHub SecurityGit Project: Team Repository CIProject
PREVIOUS LESSONGit Cherry-Pick
NEXT · UNIT PROJECTGit Project: Feature Branch
3. Branches & History 40 min

Git Tags

Mark releases with tags, distinguish lightweight pointers from annotated records, and treat published version tags as immutable.

What you will leave with

You will distinguish lightweight tag refs from annotated tag objects, point a version name at an explicit verified commit, and refuse to silently move a published release identity.

A tag gives one object a durable name

A branch ref normally moves as commits are added. A tag ref is intended to remain fixed. Teams use tags to identify releases, milestones, deployment inputs, or audited states. git tag is a Git command. GitHub Releases are a later hosting feature that typically points at a Git tag—they are not the same thing.

LIGHTWEIGHT

Direct ref

refs/tags/v1.4.0 points directly at an object, usually a commit. It carries no separate tagger message.

ANNOTATED

Tag object

The ref points to a tag object containing target, type, tag name, tagger, date, and message. The tag object then references the release commit.

Annotated tags are usually the stronger release record because the metadata explains who created the label and what it represents. Cryptographically signed tags add verification when the project has a managed signing policy.

If you just transferred a fix with Git Cherry-Pick, tag the verified destination commit—not whichever commit happens to be HEAD.

Create an annotated tag at a verified commit

git status
git show --no-patch --format=fuller <release-commit>

# Create an annotated tag at the verified commit
git tag -a v1.4.0 <release-commit> -m "Release v1.4.0"

git show v1.4.0
git rev-parse v1.4.0^{}

Pass the commit explicitly instead of assuming HEAD. The peel expression v1.4.0^{} resolves the annotated tag to its target object, normally the commit used to build the release.

Build first, tag the exact input second

Run release tests and build from a clean commit, record artifact checksums and CI evidence, then tag that same commit. A tag name cannot prove the artifact was built from it.

QUICK CHECK

Test what you learned

Type the command that creates annotated tag v1.4.0 at commit a1b2c3d with message Release v1.4.0.

List, inspect, and relate tags to history

git tag --list 'v1.*' --sort=-version:refname
git for-each-ref refs/tags --format='%(refname:short) %(objecttype) %(taggerdate:iso8601) %(subject)'
git show v1.4.0
git tag --contains <commit>
git describe --tags --always <commit>

git describe names a commit relative to a reachable tag; it does not create or move a tag. Exact output depends on reachable tags and options, so use full commit IDs for security-sensitive identity.

Publish tags explicitly

# Push one reviewed release tag
git push origin v1.4.0

# Fetch remote tags
git fetch --tags

# Push a branch plus missing reachable annotated tags
git push --follow-tags origin main

# Inspect the remote tag ref
git ls-remote --tags origin refs/tags/v1.4.0 refs/tags/v1.4.0^{}

A normal branch push does not imply “publish every local tag.” --follow-tags pushes missing annotated tags reachable from refs being pushed; it does not mean all tags, and it does not replace deliberate release publication. Pushing a tag talks to a Git remote. That remote might be GitHub, GitLab, or another host.

Treat published version tags as immutable

If a release tag points to the wrong commit, stop distribution and follow an explicit incident policy. Often the safest public correction is a new version tag plus clear release notes.

# Local deletion
git tag -d v1.4.0

# Remote deletion — destructive and coordination-sensitive
git push origin :refs/tags/v1.4.0
Deletion does not retract copies

Clones, package indexes, caches, artifacts, and deployment systems may retain the old tag and content. Never silently recreate the same public version name at a different commit.

Guided practice: tag a verified commit

  1. 01
    Choose an explicit commit

    In a disposable repository, identify the tested commit you intend to name. Do not assume HEAD.

  2. 02
    Create an annotated tag

    Use git tag -a with a version and a message that states what the name represents.

  3. 03
    Peel and compare

    Show the tag object, peel it to the commit, and confirm the tree matches the tested snapshot.

  4. 04
    Push one tag

    Publish that exact ref, then inspect the remote direct and peeled names.

  5. 05
    Refuse a silent move

    Demonstrate locally that moving the tag changes its target, then delete the experiment without publishing the moved name.

Independent lab: audited release identity

  1. Create a disposable repository with at least two commits and identify the one that represents a release.
  2. Create v1.3.1 as an annotated tag on that explicit commit.
  3. Inspect the tag object and the peeled commit. Record both object IDs.
  4. If you have a disposable remote, push only that tag and inspect it from a second clone.
  5. Move the tag locally, prove the target changed, then delete the local experiment without publishing the moved name.
Definition of done

The annotated tag targets the exact verified commit, you can peel it, and you can explain why a published version name must not be silently reused.

Common tag mistakes

Tagging whichever commit is HEAD

Name the explicit verified commit to prevent terminal context from defining a release.

Assuming tags push automatically

Publish and verify the intended tag ref explicitly.

Reusing a released version

A moved public tag creates conflicting truths across clones and artifact systems.

Calling git tag a GitHub command

Git stores the ref. GitHub Releases are a later platform feature.

Lesson review

You can distinguish tag refs from tag objects, point an annotated version name at a verified commit, and treat published tags as immutable identities. GitHub Releases, when taught later, sit on top of this Git record.

  • I can create, peel, inspect, push, and remotely verify an annotated tag.
  • I pass an explicit commit instead of assuming HEAD.
  • I treat published version tags as immutable release identities.
  • I know git tag is Git, while GitHub Releases are a hosting feature.

Related lessons

  • Git Cherry-Pick — A release often starts from a verified backport.
  • Git Log — Decorated log shows which commits tags name.
  • GitHub Pages — A GitHub Release usually points at the Git tag you already named.
  • Git Internals — An annotated tag is a Git object you can cat-file, not a GitHub Release.
KNOWLEDGE CHECK

Check your Git tag model

Name a verified commit without treating a tag as a movable branch or a GitHub-only button.

01How does an annotated tag differ from a lightweight tag?
02What does v1.4.0^{} mean when v1.4.0 is annotated?
03Does a normal git push automatically publish every local tag?
04Why should a published release tag not be silently moved?
05Is git tag a GitHub command?
PREVIOUS LESSONGit Cherry-Pick
NEXT · UNIT PROJECTGit Project: Feature Branch
ON THIS PAGEGit TagsA tag gives one object a durable nameCreate an annotated tag at a verified commitList, inspect, and relate tags to historyPublish tags explicitlyTreat published version tags as immutableGuided practice: tag a verified commitIndependent lab: audited release identityCommon tag mistakesLesson reviewKnowledge checkRelated lessons
Course contents