YoLinux: CVS Intro - Concurrent Versions System
Other YoLinux Tutorials:
CVS is primarily used as a source code contol system for text files. Programmers will generate revisions to individual source code files. A collection of these files may define a specific software release. CVS aims to manage the collection of these files and the respective revisions of the individual files that make up the collection. CVS is a command driven file checkout, update, compare and management system. CVS implements RCS for management of individual files through the use of the CVS command set. Front end web and desktop GUI systems are available to ease in the use of CVS.
By default cvs will apply recursively through sub-directories. Use the option flag "-l" to prevent this. The option "-R" explicitly defines the recursive behaviour.
Prints command flags used with cvs
Use script cvsmodules to list all modules available for check-out.
cvs co ProgABCIn this case, module "ProgABC" is a directory which will be created in your current directory with all the appropriate sub-directories and files.
The files/directories to checkout can be refered to by module name or relative path name from $CVSROOT.
To checkout a particular (previous) release or build:
cvs co -r Rel-1A ProgABCThis will checkout the files necessary for the previous build for Rel-1A. The release or "tag" name in this example is "Rel-1A".
cvs edit ProgABC/file.cThis pulls out a single file for editing without getting the whole project.
cvs unedit ProgABC/file.cAbandon work on file.
History/Status:Status of checked out working repository.
cvs status [-v] ProgABC/file.cOption "-v": Print tag information.
Check-in / Commit:
When done editing the files check-in (commit) your changes:
Check in files from within the directory. i.e. file.c must be in your current working directory.
cvs ci file.cThe second check-in example will commit the entire module. (Files, directory structure and all)
Cleanup and get rid of all the files:
cvs release -d ProgABCThe flag -d will delete all of your working sub-directories. Cvs will let you know if files have changed and prompt you for a [y/n] reply.
Add a new file to your project:
cvs add file.c
Delete a file/directory from your project:
cvs delete file.cThe additions/deletions only fully take place after a check-in (commit) of the repository is performed.
Modules:The term "ProgABC" in our example is the name of a module as defined by the modules file found in CVSROOT/modules. To add a new module:
cvs co CVSROOT/modulesThen update changes:
cvs ci -m "Add comments here" modules
The module "ProgABC" is a short name for "$CVSROOT/Prog/TypeA/ProgABC"
Tagging a build/revisionTag a revision such that the current build is known to be made up of particular releases of various files.
cvs tag Rel-1A ProgABCWhere Rel-1A is the tag name for the build of module "ProgABC"
Tag a repository (directory/module) to add the symbolic name to the "snapshot" of the current sources. Tag the repository before check-in.
If bug fixes are added afterwards, only those files which have been changed need be re-tagged.
To relocate a tag that already exists to a newer set of code:
cvs tag -F Rel-1A ProgABC
cvs diff file.cThis will compare the version of the file in your working directory with that of the original you checked out.
The following will compare the two revisions of the file.
cvs diff -r 1.1 -r 1.2 file.c
To put your project under cvs control:
Check in files from within the directory. Files must be in your current working directory. The directory referenced is the tree structure for CVS not your current path.
cvs import -m "Put text description here" cv/Working_Dir CSC startThis will place the files in your current working directory and recursively the directory structure below the current, under cvs control. CSC is a "vendor tag". start is a "release tag". The directory structure will be $CVSROOT/Proj/Working_Dir
This is to get a copy of the sources and directories with the intent that the files will not be altered but shipped off site. Code extracted from cvs with export cannot be checked-in because export does not create any administrative entries.
A tag must be specified. Thus an original release would be extracted by:
cvs export -r start ProgABCStart is the name of the first entry into cvs. See import.
cvs -d /home/Project/CVS_root init-d: Directory used for repository.
[Potential Pitfall]: If a file becomes locked and you need to remove the lock from the CVS repository remove the lock files. (files beginning with "#")
Copyright © 1999, 2000, 2001, 2002 by Greg Ippolito