0 votes
1 view
in Devops and Agile by (19.8k points)

I am having some difficulty understanding how to use tags versus branches in git.

I just moved the current version of our code from cvs to git, and now I'm going to be working on a subset of that code for a particular feature. A few other developers will be working on this as well, but not all developers in our group are going to care about this feature. Should I be creating a branch or a tag? In what situations should I be using one versus the other?

1 Answer

0 votes
by (63.4k points)

Tags are ref's that point to specific points in the git history.

Tagging is usually used to capture a point in history that's used for a marked version release (i.e. v1.0.1).

A tag is sort of a branch that does not change.

Unlike branches, tags, once being created, don't have any further history of commits.

From a technical point of view:

  • tags reside in refs/tags/ namespace and can point to tag objects (annotated and optionally GPG signed tags) or on to commit object (less used light-weight tag for local names), or in very rare cases even to tree object or blob object (e.g. GPG signature).

  • branches reside in refs/heads/ namespace and may point only to commit objects. The HEAD pointer should refer to a branch (symbolic reference) or on to a commit (detached HEAD or anonymous branch).

  • remote-tracking branches reside in refs/remotes// namespace and follow ordinary branches in a remote repository.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !