cvs cheatsheet

This is mostly lifted from A Quick and Dirty Guide to CVS found up on the University of Massachusetts at Boston Computer Sciences site.

Seeing changes:

cvs status

Updating:

cvs update [filename]

Committing changes:

cvs commit [filename]

Adding a directory:

cvs add [dirname]

Adding a new file:

cvs add [filename]

Grabbing a project:

cvs checkout [project]

Updating a local copy of a project (do this within your local directory for the project!):

cvs update -P -d

Back out of a commit:

Determine the version numbers for before and after the commit, then do this (in the example below these are 1.4 and 1.5, respectively):

cvs update -j 1.5 -j 1.4 [filename]
cvs commit [filename]

Deleting files:

rm [filename]
cvs delete [filename]

Showing difference between local and repository copies:

cvs diff [filename]

For difference with a particular version:

cvs diff -r 1.2 [filename]

Difference between two versions:

cvs diff -r 1.2 -r 1.3 [filename]

Display commit log:

cvs log [filename]

Creating a repository:

cvs -d [path] init

Starting a project:

Do this by initializing from existing files or with an empty directory. I like the empty directory method.

Go to where you keep your master repostiory and create a directory structure like,

cd cvs
mkdir myprojects
cd myprojects
mkdir project1

Then set up project1 (execute from within project1 directory),

cvs import -d project1 ProjectOne initial

In this command string “project1” is the name of the project repository, “ProjectOne” the
vendor tag and “initial” the release tag for the initial set of sources.

Once you’ve set up the project, go to your remote directory (e.g. $HOME/cvs) and do a

cvs checkout project1

to pull in the new project.

The other way to do this is to create things in a remote directory (say your $HONE) and import that into the master repository. Even though the project directory will then exist in both places it’s probably a good idea to run a “cvs checkout” from your remote directory.

Once you’ve got the new project started you can go about adding subdirectories and files using the “cvs add” and “cvs commit” commands as with any existing project.

To create a project from existing files go to the directory containing the files (this can be anywhere) and run:

cvs import projects/project1 ProjectOne imported

Here cvs will label the operation as “Imported source” and create the “projects/project1” directory under $CVSROOT to hold them. The new files will have the release tag “imported” attached to them with a vendor tag of “ProjectOne”. You can choose any directory structure you’d like, and are not required to initially create a subdirectory as shown above — the following would also work, for example:

cvs import project1 ProjectOne imported

Renaming a folder under a project:

Go to physical $CVSROOT and

mv project1 projectb

Then go to CVSROOT and

perl -pi -e 's/project1/projectb/g' *

This will fix all the internal settings, history, etc for the project under which the folder lives.

Finally do a “cvs checkout” for the affected project from your remote host to pull down everything under the new name. Delete the old folder from your local machine.