CVS Branch and Tag Primer

Jeff Semke
Pittsburgh Supercomputing Center
4/21/98

In attempting to construct a CVS repository containing multiple versions of original NetBSD source distributions, as well as our own custom modifications to each of these, I found that the CVS man page was vague and unclear.

This document assumes general familiarity with the CVS system, including the concepts of modules, the repository, and basic checkout and commit operations.

Branches and tags are very different things, though they appear similar on the outside. Understanding the difference is the key to being able to support a multi-branched repository that can change as our custom code is modified for all versions of NetBSD.

The main concepts that are addressed in this document are:

Tree structure
Code in a CVS repository can be thought of as a tree. The tree shape is not based on the directory structure of the code, but rather on the versions of the code.
Trunk
As code gets modified and is committed back to the repository, it adds another revision to extend the tree. If no branches are specified when checking out working directories, the tree simply grows in a line along the main trunk of the tree.
Tags
A tag can be used to name a particular revision of the code. This tag can later be used to compare different revisions, to go back to an earlier version, or to specify a place to create a branch.
Branches
Branches allow different development paths to be tried. They can be created from the main trunk, or from other branches.

1. The trunk of the tree

2. Branches

3. Tags

4. Merging branches