Skip to main content

How does a tag differ from a branch?

A tag and a branch in Git differ in their role and behavior in the commit history.

In short: a branch is a "live pointer," while a tag is a "fixed marker."


The main difference

  • A branch points to the last commit and moves forward with every new commit
  • A tag points to a specific commit and never changes

A simple example

History:

A---B---C---D
  • the main branch → D
  • the v1.0.0 tag → B

If a new commit is added:

A---B---C---D---E
  • mainE
  • v1.0.0 → still B

Differences by purpose

Branch

  • used for development
  • combined via merge/rebase
  • can change and be rewritten
  • often lives temporarily

Tag

  • used for versions and releases
  • does not participate in merges
  • does not change
  • fixes the state of the code

Differences in behavior

CriterionBranchTag
Moves with new commitsyesno
Can be committed toyesno
Used for developmentyesno
Marks a versionnoyes
Can be deletedyesyes (but rarely)

Frequently asked in interviews

Can you commit to a tag? No. Commits are made to a branch; a tag only points to a commit.

Can a tag be "moved"? Technically, yes (delete and recreate it), but this is bad practice for releases.


Short answer for an interview

A branch is a moving pointer to the last commit and a development tool, while a tag is an immutable marker on a specific commit, used to fix a version or a release.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.

How does a tag differ from a branch?: Git Interview Question