37.4 Introduction to CVS
CVS is suitable for synchronization purposes if individual
files are edited frequently and are stored in a 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, because all variants of a file are stored
permanently on the CVS server. 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.
37.4.1 Configuring a CVS Server
The server is the host on which 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 users 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, the following environment
variables must be set on the client side:
CVS_RSH=ssh CVSROOT=tux@server:/serverdir
The command
cvs init 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 exclusively to contain files to
manage with CVS (the directory can also be empty). The name of the
directory is also the name of the synchronization. In this example,
the directory is 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
37.4.2 Using CVS
The synchronization repository can now be checked out from all
hosts with 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 with a command like
cvs add file1
directory1 before they are committed to the server.
Subsequently, commit the newly added files and directories with
cvs commit file1
directory1.
If you change to another workstation, check out the
synchronization repository, if this has not been done during an
earlier session at the same workstation (see above).
Start the synchronization with the server with
cvs update. Update
individual files or directories as in
cvs update file1
directory1. To see the difference between the current files
and 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:
- U
-
The local version was updated. This affects all files that
are provided by the server and missing on the local system.
- M
-
The local version was modified. If there were changes on
the server, it was possible to merge the differences in the local
copy.
- P
-
The local version was patched with the version on the
server.
- C
-
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 in the same line and committed, you might get a
conflict, indicated with C.
In this case, look at the 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.
37.4.3 For More Information
This section merely offers a brief introduction to the many
possibilities of CVS. Extensive documentation is available at the
following URLs:
https://www.cvshome.org/
https://www.gnu.org/manual/