Prior to using cvs, set up the CVSROOT and EDITOR environment if not set up already.
$ export CVSROOT=/path/to/cvsroot $ export EDITOR=vi
There are only a handful of CVS commands that you need to know to get everything done to control a project. All the commands share a common general syntax of:
$ cvs [-d cvs_root_path] command [command-options-and-arguments]
- init: Create/initialize a project.
$ cvs -d /path/to/cvs/PROJECT init
This creates the named directory and makes it into a “CVS root directory”.
- import: Create/import an archive.
$ cvs -d /path/to/cvs/PROJECT import -m "CVS archive for module" module module begin
Imports the entire module tree including all subdirectories and turns it into a CVS archive in the project or default CVS root directory.
- checkout: Checkout the project module
$ cvs -d /path/to/cvs/PROJECT checkout module
Check out the module to create a new working directory from CVS.
- add: Add new files to the project
$ cvs -d /path/to/cvs/PROJECT add newdoc1 newdoc2 nedoc3...
The files has been added to CVS, but the archive file doesn’t actually exist yet. To create it, we have to “commit” the changes.
- commit: Commit changes to save to archive.
$ cvs -d /path/to/cvs/PROJECT commit
This saves all changes to the CVS archive auto-incrementing the revision number on all future commits.
- update: Update local files
$ cvs -d /path/to/cvs/PROJECT update -d .
Updates local files with the files on the CVS archive including all subdirectories.
When running an update before working on a shared project, always use the additional “-d” flag to be sure to also update any missing directories your co-workers might have added as well as the already existing working copies of the files.
- diff: Diff/compare changes between two revisions
$ cvs -d /path/to/cvs/PROJECT diff -r 1.1 -r 1.2 newdoc1
This will compare and output the differences between the two revisions of the specified file. You could also pipe this into a patch file to be used later.
- tag: Tag current set of changes
$ cvs -d /path/to/cvs/PROJECT tag version_1_0_0
Tagging revisions allows for sources to be recovered with the tag name.
Note that CVS won’t permit the “.” character in tags, so you cannot use “version.1.0.0″ as a tag. version_1_0_0 is permitted.
- remove: Remove unwanted files
$ cvs -d /path/to/cvs/PROJECT remove newdoc1
Note that file has to be removed first prior to removing it from the cvs archive. Then commit the change to actually remove the file from CVS. This puts the file into the “Attic” folder.
To get more usage info:
cvs --help # usage info and general cvs-options cvs --help-commands # list & description of commands cvs --help-options # general cvs-options cvs --help command # command specific usage & command options