Using CVS in the CSUGLab

Introduction

CVS is a revision control system that makes it easier for several people to work simultaneously on a software project while maintaining their own separate working areas. This page describes the basic commands that you need to know to start using CVS. 

Your changes to the source code are only distributed to other users when you explicitly commit your code using the "cvs commit" command. Changes made by other users are only seen by you when you explicitly request them via a "cvs update" command. CVS has many other useful features. See the CVS manual pages for a detailed description of how to use it.

 

Command Line Execution

This document is a quick introduction to using CVS from the command line, by running the cvs executable program. There are many tools and programming environments (such as Eclipse, for instance) that have built-in support and user-friendly interfaces for CVS. These tools and interfaces are not discussed here.

On Linux machines, or using Cygwin in Windows, you should be able to type "cvs" in the shell/Cygwin window. You will need to set up a CVS repository to hold your code; the CSUGLab admins can do this for you, as described below. This document also provides a quick tour of the main CVS commands.

 

CVS Repository

CVS repositories are available to students with CS Undergraduate Lab (CSUGLab) accounts for use in a course or project. The main repository is set up on a host named cvs.csuglab.cornell.edu in the /cvsroot directory.

To request such a repository, please send email to Tanya Gupta (tg74@cornell.edu) including the names and netids of your group members. The subject of the mail should be "CS 3110: CVS repository request". Your repository will only be stored until the end of the current semester. For more information on setting up CVS, see the CSUGLab CVS page.

You can access the repository either locally or remotely:

Note: you can avoid specifying the "-d" argument in two ways:

  1. by setting the environment variable CVSROOT to the appropriate value (:local:/cvsroot or :ext:<your_userid>@cvs.csuglab.cornell.edu:/cvsroot); or
     

  2. by running the commands from one of the sub-directories in your local work directory (i.e., a directory that contains a CVS/ subdirectory).

Note for Windows users: to set up environment variables in Windows, right click on the My Computer icon and choose Properties. Select the tab labeled Environment. You can also go to the Control Panel > system > advanced tab > environment variables. Under cygwin, you can set environment variables in your .bashrc file, e.g. CVS_RSH=ssh.

 

Setting up work directories

After the repository has been created, all group members should create working directories to house the files checked out of the repository.  For each user, set up the environment variables specified in the 'Setting up environment variables' section.  Then, execute the following command from a shell prompt (cygwin or a unix shell):

cvs checkout <project name>

Where <project name> is the name of the project specified when creating the repository.  This command will create a directory with the name <project name> and containing all files and subdirectories contained in the project.

 

Basic Usage

  1. To check out all of the files in the repository, execute:

    cvs -d :ext:<your_netid>@cvs.csuglab.cornell.edu:/cvsroot checkout <repository>

     

  2. To obtain the latest version of a file, execute :

    cvs update <filename>

    Note1
    : You may find it convenient to update multiple files at once. For this, go to a subdirectory, and type "cvs update". All files in that directory and its subdirectories will get updated.

    Note2:  If new directories have been created since the last time you did an update, those directories will not get retrieved by "cvs update". To force updating new subdirectories, use "cvs update -d".

     

  3. To put a modified file in the repository, execute :

    cvs commit -m "<comment>" <filename>

    Note1: If you omit the -m "<comment>" argument, CVS will ask you to open an editor and enter a message for your changes.

    Note2
    : You may find it convenient to commit multiple files at once. For this, go to a subdirectory, and type "cvs commit". All files in that directory and its subdirectories will get committed.

     

  4. To add a new file (or directory) to the repository, execute :

    cvs add <filename>

    Note
    : You must commit the file after adding it before other group members can check it out.

     

  5. To remove a file from the repository, execute :

    cvs remove <filename>

    Note
    : You must commit the file before it is actually removed.

     

  6. To view the differences between a file in the working directory and the repository, execute :

    cvs diff <filename>

     

  7. Several commands (e.g., checkout, update, and diff) support an argument "-D <some date>" to perform the specified operation against an older version of the code. This feature is very useful when you want to resort to an older version when the current one appears to have problems. CVS supports a variety of different ways for expressing dates. Here some examples:

    cvs checkout -D "2 hours ago"
    cvs checkout -D "yesterday"
    cvs checkout -D "9/22/06"
    cvs checkout -D "9/22/06 10:00am"

 

More information

See the on-line documentation for further information on using CVS.