home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Unix Power ToolsUnix Power ToolsSearch this book

39.7. CVS Basics

The Concurrent Version System, or CVS, is a version control system designed to support complex project structures or groups of people who are working together on a common set of files. Where RCS (Section 39.5) deals only with individual files, CVS allows you to work with entire projects as a whole. As we have mentioned before, while source control systems were originally developed primarily for use in developing software, they make a great deal of sense any time you want to keep track of changes to files. CVS is good for keeping track of changes to source files for a book or configuration files for qmail or apache, or for any number of other day-to-day tasks.

CVS stores its archives in a directory called a cvsroot. You tell CVS where to find the repository you want to use by setting the CVSROOT environment variable or using the -d option:

% setenv CVSROOT /home/cvsroot
% cvs checkout conf

% cvs -d /home/deb/cvs checkout book

Within a cvsroot are one or more repositories. Each repository is associated with a particular project (or in the case of a very complex project, a piece of a project). To work on a project, you much check out its repository to create a working area using cvs checkout, as in the example above. CVS is helpful and remembers which cvsroot you used for a particular checkout; future commands within that working area automatically use the right repository. For the record, the working area's cvsroot overrides the CVSROOT environment variable; the -d option overrides them both.

Once you have a working area, you have a writable copy of every file in that project. Edit to your heart's content. To incorporate changes made by other people, or see what you've changed, use cvs update:

% cd book
% cvs update
cvs update: Updating .
U ch18.sgm
M ch39.sgm

CVS update tells you a bit of information about each file that it touched or needs to touch. A U means that it updated your working copy from the repository; if you had also changed that file, it means that CVS successfully merged their changes with yours. A M means that you've modified that file in your working area.

To push your modifications into the repository, you use cvs commit. As the name suggests, this commits your changes. Generally you'll want to do this often, so that you aren't set back very far if you delete a file accidentally or make a change you later decide you don't want.

CVS does more, of course. For example, cvs log lets you read the log that shows differences between two revisions. cvs diff lets you see the differences between two revisions by comparing them with diff (Section 11.1). cvs add (followed by cvs commit) adds a new file or directory to the repository. cvs remove removes a file or directory; be sure to remove any local copy first, or use cvs remove -f to have CVS remove your local copy for you. cvs init initializes a new cvsroot, and cvs import creates a new repository. Notifications can be emailed automatically when a file is changed. Part or all of the repository can be made read-only for all but a few users -- so you can share files freely but prevent unauthorized changes. O'Reilly's CVS Pocket Reference gives a summary of all this and much more about CVS.


Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.