Intro to CVS


Back to cs180

CVS stands for Concurrent Versions System.  Its benefits are two-fold.  One of the great things that CVS does is that it tracks changes in your files.  Therefore if you ever decide that you wish that you hadn't made some changes to a file, you can always revert to the version of your files before the change was made.  I'm sure we've all experienced that nasty error that creeps into our code when we're doing last minute addition of comments.  CVS can help to avoid that problem.

The other really cool thing that CVS does is inherent in its name; namely "concurrency."  CVS allows many different users to work on the same files at the same time without the need to worry about overwriting what someone else has been slaving over for the past few hours or even days.

The following are links to the CVS homepage and a fairly decent tutorial on how to get up and running with CVS:

CVS is installed on the lab machines, but in order to make it work you need to set up a cvsroot directory.  The following instructions should be sufficient to get you started.

Getting set up

1.  In your home directory create a directory called ".cvsroot"

   > mkdir .cvsroot
2.  Open the file ".bashrc". At the end of the file insert the following:

   # Set path for cvsroot directory
   CVSROOT=$HOME/\.cvsroot
   export CVSROOT


Save and close the file.
3.  Close the shell that you have been working in and open another shell. At the command prompt type:

   > env

A list of environmental variable should appear.  Somewhere in there you should see CVSROOT. If you don't see CVSROOT anywhere, log off and log back in and try this step again. (I can't remember if this is necessary to refresh the environment variables or not.)
4.  Now type:

    cvs init

You should now be ready to use CVS!


Starting a Project

1.  The first thing that you need is some files.  Anything should do, but if you don't have any lying around, download these triangle.tgz.
2.  Create a directory for the files:
   > mkdir triangle
3.  Put the tarball in the directory and unpack it and then delete the tarball:

        > mv triangle.tgz triangle/
        > cd triangle
        > tar -xzvf triangle.tgz
        > rm -rf triangle.tgz
4.  Now register these files with CVS

   > cvs import -m "Starting Triangle Project" triangle testing start

You should see something like the following:

   > < "Starting Triangle Project" triangle testing start
   > N triangle/Makefile
   > N triangle/triangle.h
   > N triangle/triangle.cpp
   > N triangle/trigen.cpp
   > No conflicts created by this import
5.  Delete the triangle directory and all of its contents.  No, really, delete them.
6.  Cd to your home directory and type the following:

   > cvs checkout triangle

You should see something like the following:

   >> cvs checkout: Updating triangle
   > U triangle/Makefile
   > U triangle/triangle.cpp
   > U triangle/triangle.h
   > U triangle/trigen.cpp
7.  A new folder called triangle should have been created in your home directory. Cd to that directory and you will find the files that you just deleted as well as a directory called CVS which holds information used by the program. (don't modify anything in there)
8.  At this point your ready to go.  So, rather than me continuing to repeat what the tutorial tells you to do; open the link to the tutorial, (or read the manual, or find a tutorial that you like better) and learn how to update, commit, checkout, etc.

Tim Mauch
Last modified: Sun Sep 28 14:52:48 PDT 2003