CVS
Introduction
CVS ("Concurrent Versions System") is a version control system for software
development projects. It allows you to keep change histories on individual
source files, and to tag a particular snapshot of all files as belonging to
the same release. It also supports other operations useful in the context
of team programming.
CVS is part of the GNU Project and is
freely distributed in the open source community. (GNU does many commonly
used UNIX utilities like emacs, make, gcc, and gdb. See their "Free Software Directory" for a
complete list.)
Why use CVS?
CVS solves a number of problems in the context of software development.
- It provides change histories. Suppose you make several changes to
a source file and it ends up breaking something? CVS allows you to keep a
change history so that you can review how a source file has been modified.
This is particularly important in team contexts when other people are
changing the same set of files.
- It supports rollbacks. Along with source file change histories,
CVS saves previous versions of each source file so that a developer can
rollback to any previous version at will. This can be a powerful tool when
debugging.
- It provides release tagging. At some point, a snapshot of the
current working system can be tagged with a particular version number.
This will add a tag to all source files, and allow a developer to rollback
the entire project to a particular point for debugging or other purposes.
- It backs up previous versions of source code in a compact format.
One could always save a copy of source files at various times to create a
change history and allow rollbacks. This is inefficient, however, since
multiple copies of things that don't change are also saved and the disk
space needed quickly grows. CVS provides a compact solution by internally
saving only the differences between file versions, but still
allowing any version to be restored in its entirety.
- It provides merging capabilities. Two developers working on
the same source file independently can merge their changes. Source code
can also be branched, and the branches merged together at some later time.
Some basic commands
Here are a few commands to give you an idea of how to use CVS. This list
is hardly complete, but is meant simply to illustrate several typical
operations. (See the links in the next section for a more detailed
treatement of CVS commands.)
First, set your environment variable to your CVS repository directory.
This is where CVS will store source files, differences, version
information, etc.
setenv CVSROOT=mycvsrootdir
To create a source repository, cd to your source directory and use:
cvs import -m MESSAGE MODULE VENDER_TAG RELEASE_TAG
Once a repository is created, you can cd to any directory and "checkout"
the source tree. This will copy it into your directory.
cvs checkout [-r REV] [-d DIR] MODULE
To add source files to a project:
cvs add -m MESSAGE file1 file2 file3
Remember that "checkout" in CVS means copying a source tree into your
current working directory. Unlike some other source control systems, there is
no concept of checking a file out before working on modifications in CVS.
Instead, you simply make the modifications, and then "commit" the changes
using:
cvs commit
To create a snapshot, you tag all files in the module:
cvs tag TAG_NAME
To look at a file's history:
cvs history file1
Useful CVS Links
GNU CVS manual
One
of many online tutorials
CVS FAQ
CVS FAQ page
written by UNC's DiRT research group
David Ott (ott@cs.unc.edu)
Last modified: 12 August 2002