YoLinux: CVS Intro - Concurrent Versions System

CM Tutorials:


°Subversion and Trac server intall/config



°Subversion vs Clearcase

Other YoLinux Tutorials:

°Software development tools

°Advanced VI

°Emacs and C/C++

°C++ Info, links

°MS/Visual C++ Practices

°C++ Memory corruption and leaks

°C++ String Class

°C++ STL vector, list

°Posix Threads

°Fork and Exec

°GDK Threads

°Clearcase Commands

°YoLinux Tutorials Index

Free Information Technology Magazines and Document Downloads
TradePub link image

CVS Intro:

CVS is primarily used as a source code contol system for text files. Programmers will generate revisions to individual source code files. A collection of these files may define a specific software release. CVS aims to manage the collection of these files and the respective revisions of the individual files that make up the collection. CVS is a command driven file checkout, update, compare and management system. CVS implements RCS for management of individual files through the use of the CVS command set. Front end web and desktop GUI systems are available to ease in the use of CVS.

Information Links:

Version control tools for Linux http://linas.org/linux/cmvc.html
Extensive CVS information http://www.cs.utah.edu/dept/old/texinfo/cvs/cvs_toc.html
Gnome: Pharmacy http://pharmacy.sourceforge.net/
KDE/QT: LinCVS http://www.lincvs.org//
gCvs - C++ CVS client front ends for multiple platforms. http://www.wincvs.org/
TkCVS - CVS client front end http://www.twobarleycorns.net/tkcvs.html
ViewVC - Web front-end http://www.viewvc.org/
CVS web - front end (simple) http://www.freebsd.org/projects/cvsweb.html
LXR - Linux Cross Referencing Tool
        (Web front end to CVS)
Glimpse: search engine used by XLR http://glimpse.cs.arizona.edu (also see WebGlimpse.net)
jCVS - JAVA front end to CVS jCVS
JAVA-CVS http://www.hungry.com
KDE/QT: Cervisia http://cervisia.sourceforge.net/

Setting up your environment for CVS:

  • Set environment variables: (add to your .bashrc file)

    Environment variables:

          export CVSROOT='/home/Project/CVS_root'     - directory for CVS source code repository
          export CVSEDITOR=/bin/vi

  • Set environment variables: (add to your .cshrc file) (for csh users)

    Environment variables:

          setenv CVSROOT  '/home/Project/CVS_root'
    setenv CVSEDITOR /bin/vi

  • CVSROOT: Location of CV source code repository.

Example use of CVS: (Project already created. If not created see "Creating CVS repository for the first time" below.)

By default cvs will apply recursively through sub-directories. Use the option flag "-l" to prevent this. The option "-R" explicitly defines the recursive behaviour.

Prints command flags used with cvs

      cvs -H 

Use script cvsmodules to list all modules available for check-out.


      cvs co ProgABC
In this case, module "ProgABC" is a directory which will be created in your current directory with all the appropriate sub-directories and files.

The files/directories to checkout can be refered to by module name or relative path name from $CVSROOT.

To checkout a particular (previous) release or build:

      cvs co -r Rel-1A ProgABC
This will checkout the files necessary for the previous build for Rel-1A. The release or "tag" name in this example is "Rel-1A".

      cvs edit ProgABC/file.c
This pulls out a single file for editing without getting the whole project.
      cvs unedit ProgABC/file.c
Abandon work on file.


Status of checked out working repository.
      cvs status [-v] ProgABC/file.c
OR cvs status [-v] ProgABC
Option "-v": Print tag information.

Check-in / Commit:

When done editing the files check-in (commit) your changes:

Check in files from within the directory. i.e. file.c must be in your current working directory.

      cvs ci file.c
OR cvs ci -m "Put text description here" file.c OR cvs ci -m "Put text description here" ProgABC
The second check-in example will commit the entire module. (Files, directory structure and all)

Cleanup and get rid of all the files:

      cvs release -d ProgABC 
The flag -d will delete all of your working sub-directories. Cvs will let you know if files have changed and prompt you for a [y/n] reply.

Add a new file to your project:

      cvs add file.c         

Delete a file/directory from your project:

      cvs delete file.c         
The additions/deletions only fully take place after a check-in (commit) of the repository is performed.


The term "ProgABC" in our example is the name of a module as defined by the modules file found in CVSROOT/modules. To add a new module:
      cvs co CVSROOT/modules
vi modules - Add module name and path to file

Then update changes:
      cvs ci -m "Add comments here" modules
cd ..
cvs release -d CVSROOT

The module "ProgABC" is a short name for "$CVSROOT/Prog/TypeA/ProgABC"

Tagging a build/revision

Tag a revision such that the current build is known to be made up of particular releases of various files.

      cvs tag Rel-1A ProgABC 
Where Rel-1A is the tag name for the build of module "ProgABC"

Tag a repository (directory/module) to add the symbolic name to the "snapshot" of the current sources. Tag the repository before check-in.

If bug fixes are added afterwards, only those files which have been changed need be re-tagged.

To relocate a tag that already exists to a newer set of code:

      cvs tag -F Rel-1A ProgABC 


      cvs diff file.c 
This will compare the version of the file in your working directory with that of the original you checked out.

The following will compare the two revisions of the file.

      cvs diff -r 1.1 -r 1.2 file.c 

Starting a new project:

To put your project under cvs control:

Check in files from within the directory. Files must be in your current working directory. The directory referenced is the tree structure for CVS not your current path.

      cvs import -m "Put text description here" cv/Working_Dir CSC start
This will place the files in your current working directory and recursively the directory structure below the current, under cvs control. CSC is a "vendor tag". start is a "release tag". The directory structure will be $CVSROOT/Proj/Working_Dir


This is to get a copy of the sources and directories with the intent that the files will not be altered but shipped off site. Code extracted from cvs with export cannot be checked-in because export does not create any administrative entries.

A tag must be specified. Thus an original release would be extracted by:

      cvs export -r start ProgABC 
Start is the name of the first entry into cvs. See import.

Creating CVS repository for the first time:

      cvs -d /home/Project/CVS_root init
-d: Directory used for repository.


[Potential Pitfall]: If a file becomes locked and you need to remove the lock from the CVS repository remove the lock files. (files beginning with "#")


Also see:


  • CVS Home.org - Links and info.
  • Subversion - version control system (not CVS) Next generation revision control system to handle directory revisions and things CVS can not currently handle.
  • Gentoo CVS tutorial


"Open Source Development with CVS"
Karl Fogel
ISBN #158880173X, Coriolis Open Press.

The only book I know of which is totally dedicated to the topic of CVS.



    Bookmark and Share


Copyright © 1999, 2000, 2001, 2002 by Greg Ippolito