CVS QuickReference

Unix

Commands

  • cvs import
    When adding a new project to an existing cvs repository, you need to use the import command. Basically, go into the directory you wish to import, and run this command: cvs import nameofyourcode yourusername start - for example, if I am adding my rsim project to the repository, I would run cvs import rsim kwheeler start. Once you have done that, go to another directory, and check your code out (using the checkout command, described below) before you start working on it again.
  • cvs update or cvs up
    The single most important cvs command is update. Use it frequently. What it does is synchronizes the files you're working on with the latest changes that other people have made. It updates the current directory and all the directories within it. If someone else has modified the files you're working on, those changes will be merged with your changes. If there are conflicts (i.e. you modified line 48 and so did someone else, and that someone else committed before you did), cvs will tell you. Edit the file (cvs will clearly mark the conflict), resolve the conflict, and update/commit it.
  • cvs checkout or cvs co
    Use this command to pull down a fresh working copy of the files in the repository. You can pull down either the whole nnsim directory, or just subdirectories. Like this:
        cvs co nnsim/com/pioneer
    To pull down everything:
        cvs co nnsim
  • cvs commit
    Use this command to add your changes to the repository. If you don't give it specific filenames, this command commits the current directory and all subdirectories. Unless you're sure that no one else has committed changes to the files you're working on to repository, you probably want to run cvs up first. When you commit, this command will use your EDITOR envariable to prompt you to add a comment for the files you commit. Please be both descriptive and concise. For the sanity of those working with you, don't commit code that doesn't compile.
  • cvs add
    Use this command to add files and directories to the repository. What this command really does depends on what you're adding. If you cvs add a directory, cvs adds a CVS directory to that directory, and schedules the directory for adding (but does NOT add the files in that directory). If you add a file, it marks that file to be added to the repository. After you mark everything you want to add for adding using this command, you must use cvs commit to actually send it all to the repository.
  • cvs delete or cvs rm or cvs del
    This command removes files from the repository (not directories... those are tricky, and in truth, never go away. It's complicated.). To remove a file from the repository, first delete the file, then cvs delete it. Like this:
        rm whatWasIThinking.c
        cvs rm whatWasIThinking.c
  • cvs diff
    This command uses diff to show you what has changed between the local version of a file and the version stored in the repository. This may produce a lot of output, so... use like this:
        cvs diff whatDidIChange.c | less
Note: There are, of course, many more commands and options to pass to these commands.

Environment

CVSROOT

There are three primary environment variables that CVS pays attention to that you will probably want to set before you use it. The first, and most important is CVSROOT. This variable defines where cvs goes looking for all the behind-the-scenes files. For our (spanid's) purposes, set this to the cvsroot directory in /afs/nd.edu/user37/spanids/CVSROOT/. If you have AFS mounted on the machine you're working on, this is easy:

  • Bash: export CVSROOT=/afs/nd.edu/user37/spanids/CVSROOT
  • Csh/Tcsh: setenv CVSROOT /afs/nd.edu/user37/spanids/CVSROOT
If you don't have AFS set up on the machine you're working on, you have to provide a little more information - specifically, a host that *does* have access to our cvsroot:
  • Bash: export CVSROOT=yourusername@cse.nd.edu:/afs/nd.edu/user37/spanids/CVSROOT
  • Csh/Tcsh: setenv CVSROOT yourusername@cse.nd.edu:/afs/nd.edu/user37/spanids/CVSROOT
CVS_RSH

The second most important environment variable is CVS_RSH. If you have AFS mounted on the machine you're working on, this variable is unimportant. If you don't have AFS mounted, you want to set this variable to 'ssh'.

  • Bash: export CVS_RSH=ssh
  • Csh/Tcsh: setenv CVS_RSH ssh
If you use the ssh option, you will have to authenticate yourself with ssh for each and every cvs command, which can get irritating. I suggest either figuring out how to get ssh public/private keys working on wizard or some other machine with AFS access (good luck), or looking more seriously into mounting AFS locally.
EDITOR

The third most important environment variable is EDITOR, which sets what program will be used to add comments to the cvs log describing your commit's (please, always try to make these descriptive). You probably want to set this to be emacs or vim.

What is this .cvsignore file?

The .cvsignore file tells cvs to not pay any attention to the files (or directories) listed in it. The format is one file name per line, with shell-style wildcards allowed. Since CVS really shines with text-files and not so much with binary files (it has to keep a every copy of each binary file, instead of just keeping the differences from the previous version like it can with text files), you probably don't want to store binary files in the repository unless they really won't change very often (.gif files are fine to add, while adding java .class files is probably unwise). To make life easier, you can just add (for example) the line *.class to the .cvsignore file in a directory containing java files, and cvs won't even bother with those class files.