==================== A Quick Guide to CVS ==================== T.A. Gonsalves TeNeT Group, IIT-Madras 10 July 2003 $Id$ ---------------------------------------------------------------- T A B L E O F C O N T E N T S ---------------------------------------------------------------- 1. Introduction 2. Quick Guide 2.1 Create a Repository 2.2 Starting a New Project 2.3 Adding a File to the Project 2.4 Editing Files 2.5 Defining Modules 2.6 Tags 2.7 Information about the Repository 3. Hints for Developers 4. For Further Information ---------------------------------------------------------------- 1. Introduction =============== CVS maintains a shared repository for several projects. It is intended for use with projects consisting of many modules being written concurrently by a large team of programmers. Some key features of CVS: * a project consists of a number of modules organised in one directory sub-tree * the repository can be accessed from Unix, Linux, Windows, etc. over a network * the default is non-locking, i.e., several programmers can simultaneously edit a file. The first person to commit the file succeeds, the others must merge their changes. * each time a file is committed to the repository, CVS automatically increments its revision number * a project or module can be given a tag, say Rel_1_3. CVS maintains the mapping between the tag and the corresponding revisions of every file in the project or module * CVS is built on top of RCS For complete details, read the CVS man or info pages. 2. Quick Guide ============== In this guide, lines beginning with '>' indicate commands to be typed. '[...]' indicates an optional argument. '<...>' should be replaced by your own argument such as a file name. 2.1 Create a Repository ----------------------- > cvs [-d ] init The default repPath is given by the environment variable CVSROOT. For example, CVSROOT='lantana:/safe/cvs' creates a repository in /safe/cvs on Lantana. The repository has a directory /CVSROOT/ that contains administrative files used by CVS. 2.2 Starting a New Project -------------------------- Follow these steps: 1. Make a working directory tree, . If this is a new project, the directory tree may not contain any files. For an existing project that is being imported into CVS, the subdirectories would contain files. 2. > cd 3. > cvs import initial start 4. > cd .. 5. > cvs checkout This creates a directory $CVSROOT/ that contains the repository copies of the files under . Usually, is the same as . Note that each directory under will have have a sub-directory named 'CVS'. 2.3 Adding a File to the Project -------------------------------- Create a file, say myfile.c, in some directory of your working directory tree. Near the top of the file, put a comment containing the string '$Id$' and '$Log$'. For example: /* $Id$ */ ... /* $Log$ */ When CVS commits the file, the $Id$ keyword is replaced by the current revision number. CVS appends a log message to the $Log$ keyword. Now, add the file to the repository using: > cvs add myfile.c > cvs commit -m "" myfile.c CVS saves revision 1.1 of myfile.c, with the $Log$ keyword substituted with . To see the details of the files in the repository with the revisions and log messages of each: > cvs log Note that if you omit the '-m ...' option, CVS will run an editor for you to enter the log message. It looks for the editor name in the environment variables CVSEDITOR and EDITOR, then defaults to vi. 2.4 Editing Files ----------------- Checkout the file into your working directory, edit it and commit the changes. After you are done, you can release the working directory. > cd / > cvs checkout -d . // ... edit the file ... > cvs [-m "..."] To edit several files, checkout all files in a directory subtree, edit some and commit the subtree. CVS will checkin only edited files. > cd > cvs checkout -d . / ... edit files ... > cvs [-m "..."] . After development if complete, to release the working directory: > cvs release -d / This deletes the subtree . The files can always be checked out of the repository later. 2.5 Defining Modules -------------------- In a large project, each team member may work on a logically separate part of the project. CVS allows you to define these as modules. To define a module, you need to edit the list of modules in the CVS admininstrative directory. > cvs > cvs checkout $CVSROOT/modules > cd CVSROOT ... edit the file modules, add a line of the form: / > cvs commit -m "..." modules > cd .. > cvs release -d CVSROOT You can define aliases for modules and also specify actions to be taken each time as module is checked in or checked out, such as sending e-mail to interested persons. 2.6 Tags -------- Each file in a module has its own revision number such as 1.3 which is incremented every time the module is checked in. When the module is released, it has a release tag such as R2_7. CVS remembers the revision numbers of every file that correspond to this release tag. To add a new tag to a module: > cd > cvs tag R2_7 . ...applies to the subtree of . > cvs status -v . ...shows tags and revisions > cvs checkout -r R2_7 ...checkout files corresponding to R2_7 2.7 Information about the Repository ------------------------------------ > cvs status -v . ...shows tags and revisions > cvs log ...shows log messages of every revision of 3. Hints for Developers ======================= If you are working on one module in a project, say CygNet/Alarms/Client, you would first create a working directory tree ~/CygNet/Alarms/Client. Now, create a symbolic link: > ln -s ~CygNet/Alarms/Client ~/Client 4. For Further Information ========================== This is only the tip of the iceberg. For full details, read the online manual and info pages: > man cvs > info cvs ---------------- $Log$ ----------------