Snarfelled from: http://isoar.ca/~andrewm/programming/cvs.html
and cleand up a bit 050319

CVS Quick Reference

Updated Nov 19, 2004
 
Counter

Weaknesses of CVS

CVS is not perfect. It has few weaknesses that you either learn to live with, or you find another source code tracking package that has a completely different set of weaknesses (there's no perfect solution).

Create New Repository

To create a new empty local CVS repository:

cvs -d /path/to/repository/directory init

Create New Project

To create a new empty project in an existing repository:

mkdir project_name
cd project_name
cvs -d /path/to/repository/directory import project_name VENDOR RELEASE

The VENDOR branch and RELEASE tag are ignored since there are no files in the project yet, but they must still be specified (anything will do).

Get Working Copy of Project From Repository

To use an existing project:

cvs -d /path/to/repository/directory checkout project_name
cd project_name

Once you checkout a project, you don't have to specify the repository path with -d (or CVSROOT, see below) again!  The repository is recorded in each sub-directory in special files in the CVS/ sub-directory.

Compare Local Project to Repository

To see changes between the local project and the repository project:

cvs diff -u

It is a good idea to do this before committing changes to the repository (see below), to make sure you commit what you want.

Save to Repository

To save local project changes to the repository project:

cvs commit

If no files or directories are specified, all files are examined.  Watch out for conflicts!  Conflicts can happen when another user commits before you do.  If you are committing a lot of files:

cvs commit 2>&1 | tee commit.log

will record all messages to a file called commit.log

Update Local Project

To apply any repository changes to the local project:

cvs update -dP

The -d option creates local directories that were added to the project.  The -P option prunes local directories that were removed from the project.

Add To Project

To add a directory to a project:

cvs add directory

To add a TEXT file to a project:

cvs add filename
cvs commit filename

To add a BINARY file to a project:

cvs add -kb filename
cvs commit filename

Remove From Project

To remove a file or directory from a project:

rm -rf filename_or_directory
cvs remove filename_or_directory
cvs commit

The file or directory is moved to the "Attic" in the repository, but not really deleted from it.

Tagging

To tag a project (or file) for later reference:

cvs tag TAG_NAME

You should tag everything everytime you make a release, or otherwise want to mark a change set.  Examples:  milestones, new feature added, etc.  A tag is the only way you can mark a change to multiple files for later reference, so use them! Tags can be removed with:

cvs tag -d TAG_NAME

For info on a file, including tags:

cvs status -v filename

Importing Other's Source

To add third party source to the repository for tracking:

mkdir import_dir
cd import_dir
# Place the third party software in this directory
# Example: tar xzf source.tar.gz
cvs -d /path/to/repository/directory import project_name VENDOR RELEASE

This adds to the VENDOR branch and tags all the files with RELEASE.  This does NOT change anything else!  If you want to apply any imported changes, you must do that separately!  This is a topic for later, as it deals with merging changes on different branches (easy to do, but often difficult to understand).

Shortcuts

*nix users are lazy typists. It's a fact, and the basis for many cryptic commands (like cp for copying).

If you are tired of typing:

-d /path/to/repository/directory

You can set CVSROOT environment variable and then you don't have to specify it!

CVSROOT=/path/to/repository/directory
export CVSROOT

When you use -d it overrides CVSROOT. Often handy to put CVSROOT in your ~/.bashrc file so it is set automatically for every new shell.

Only have a short comment for the log entry on a commit or import? You can specify one with -m instead of using the editor (vi).  I don't recommend this for multiple line comments.  Example:

cvs commit -m "Fixed a bug"

Most CVS commands can be abbreviated.  See the documentation.

Remote Repository Access

To access a private repository on a remote machine via ssh:

CVS_RSH=ssh
CVSROOT=:ext:user@host.com:/path/to/repository/directory
cvs some_cvs_command
password: your_login_password

The remote user must have a valid login shell on the remote machine. You will be asked for a password on every cvs command.

HINT:  If the remote machine has your public ssh key (id_dsa.pub) in its authorized_keys2 file, you won't be asked to enter a password!

Most multi-user repositories use the CVS "pserver" service:

CVSROOT=:pserver:user@host.com:/path/to/repository/directory
cvs login
password: your_cvs_password
cvs some_cvs_command

You will only be asked for a password once!  It is stored in the .cvspass file in your home directory.  The user and password apply ONLY to the CVS account, and not necessarily to a shell account.


Search Map ValidHTML 4.01!Valid CSS!