CVS Cheat Sheet

Switch to git

Ignore the below; instead use git!

Make a new repository

cvs -d ~/cvsroot init

Make a new CVS-managed directory tree

mkdir emptydir; cd emptydir
cvs -d ~/cvsroot import -m 'CS351 course work' cs351 vendor-tag release-tag
cd ..; rm -rf emptydir
The ``vendor-tag'' and ``release-tag'' are not important in this context. (They are used when importing a directory tree populated with some other organization's code.) Just use something random.

Make a sandbox

cvs -d ~/cvsroot checkout cs351

Play in sandbox

Bring sandbox up to latest version in repository

This does not modify the repository, only your sandbox.
cvs update

Commit changes to repository

cvs commit -m 'log file entry' file.cc

Add a new file to repository

cvs add foo.cc
cvs commit -m 'foonly class' foo.cc

Add a new directory to the directory tree

mkdir assignment1
cvs add assignment1

Delete a file from repository

rm file.cc
cvs remove -m 'no longer in use' file.cc
Note that the file continues to exist in the repository in that you can fetch old versions, examine its log, etc.

Set default repository

This serves instead of the -d ~/cvsroot switch.
export CVSROOT=~/cvsroot

Advanced play in sandbox

History

Difference between file in sandbox and head version in repository.
cvs diff file.cc
Examine history of a file. Works even if file is deleted in current version.
cvs log file.cc | more
Difference between specified versions.
cvs diff -r1.23 -r1.24 file.cc
Request particular version from repository. Works even if file is deleted in current version.
cvs update -r1.23 file.cc
Request head version from repository.
cvs update -A file.cc

Symbolic labels

Label current version in repository with symbolic tag.
cvs tag handin-28-Jan-2001 foo.c bar.c foo.h bar.h Makefile

Tricks for tracking

To track files exported from CVS by printing etc, include this at the top. CVS automatically fills in the requested information.
// CVS version control block - do not edit manually
//  $RCSfile$
//  $Revision$
//  $Date$
//  $Source$
You can put similar comments in Makefiles. You can also have the program print the version upon invocation, as a debugging aid:
  cerr << "foo $Revision$ $Date$" << endl;

EMACS and CVS

Emacs has a nice interface to cvs. You check things out from outside emacs, but when editing it rocks. The modeline displays the CVS revision number. To talk to CVS do
M-x cvs-update
In the resulting *cvs* buffer go: C-h m for documentation on available commands.

Important *cvs* buffer commands:

 a    - add
 c    - commit, then C-c C-c in the resulting CVS log entry buffer
 d d  - diff against repository

Barak Pearlmutter <bap@cs.unm.edu>