16.5. Introduction to CVS

16.5.1. Uses

CVS is suitable for synchronization purposes if individual files are edited frequently and are stored in a loose file format, such as ASCII text or program source text. The use of CVS for synchronizing data in other formats, such as JPEG files, is possible, but leads to large amounts of data, as all variants of a file are stored permanently on the CVS server. Furthermore, in such cases most of the capabilities of CVS cannot be used.

The use of CVS for synchronizing files is only possible if all workstations can access the same server. In contrast, with the program Unison the data can be passed by host A through the hosts B and C to the server S.

16.5.2. Configuring a CVS Server

The server is the place where all valid files are located, including the latest versions of all files. Any stationary workstation can be used as a server. If possible, the data of the CVS repository should be included in regular backups.

When configuring a CVS server, it might be a good idea to grant the user access to the server via ssh. If the user is known to the server as tux and the CVS software is installed on the server as well as on the client (e.g., notebook), the following environment variables must be set on the client side:

CVS_RSH=ssh CVS_ROOT=tux@server:/serverdir

The command cvsinit can be used to initialize the CVS server from the client side. This needs to be done only once.

Finally, the synchronization must be assigned a name. Select or create a directory on the client that will exclusively contain files to manage with CVS (the directory can also be empty). The name of the directory will also be the name of the synchronization. In our example, we use a directory called synchome. Change to this directory and enter the following command to set the synchronization name to synchome:

cvs import synchome tux wilber

Many CVS commands require a comment. For this purpose, CVS starts an editor (the editor defined in the environment variable $EDITOR or vi if no editor was defined). The editor call can be circumvented by entering the comment in advance on the command line, such as in the following example:

cvs import -m 'this is a test' synchome tux wilber

16.5.3. Using CVS

From now on, the synchronization repository can be “checked out” from all hosts:

cvs co synchome

This creates a new subdirectory synchome on the client. To commit your changes to the server, change to the directory synchome (or one of its subdirectories) and enter cvs commit.

By default, all files (including subdirectories) are committed to the server. To commit only individual files or directories, specify them as in cvs commit file1 directory1. New files and directories must be added to the repository before they are committed to the server with a command like cvs add file1 directory1. Subsequently, the newly added files and directories can be committed: cvs commit file1 directory1.

If you change to another workstation, “check out” the synchronization repository, provided this has not been done during an earlier session at the same workstation (see above).

The synchronization with the server is started with the command cvs update. You can also update individual files or directories as in cvs update file1 directory1. If you first want to see the difference from the versions stored on the server, use the command cvs diff or cvs diff file1 directory1. Use cvs -nq update to see which files would be affected by an update.

Here are some of the status symbols displayed during an update:


The local version was updated.


The local version was modified. If there were changes on the server, it was possible to merge the differences in the local copy.


The local version was patched with the version on the server.


The local file conflicts with current version in the repository.


This file does not exist in CVS.

The status M indicates a locally modified file. Either commit the local copy to the server or remove the local file and run the update again. In this case, the missing file is retrieved from the server. If you commit a locally modified file and the file was changed and commited before in the same line, you might get a conflict indicated with C.

In this case look at conflict marks (»> and «<) in the file and decide between the two versions. As this can be a rather unpleasant job, you might decide to abandon your changes, delete the local file, and enter cvs up to retrieve the current version from the server.

16.5.4. More Information

This section merely offers a brief introduction to the many possibilities of CVS. Extensive documentation is available at the following URLs: