========================================================================= CVS Tutorial - by Colby O'Donnell - colbster (at) cs (dot) wisc (dot) edu Last Modified: October 12, 1997 This file serves as a simple step-by-step tutorial, explaining how to administer and use CVS in a project setting. Our Computer Science Dept uses the AFS file system, so this document deals with AFS directory permission as apposed to standard Unix file permissions. In this particular project, Colby is going to host the CVS repository, where master files are kept. Colby , Alexey , and Suan , are members of their CS736 Project 2 group, for Operating Systems Class. The Project name will be cs736-p2. ========================================================================= =============== ONE TIME ONLY =============== Colby first creates the CVS repository, which will live on his account. {alfred:colbster} (~)% mkdir -p CVS/CVSROOT {alfred:colbster} (~)% cd cs/736 {alfred:colbster} (~/cs/736)% mkdir cs736-p2 {alfred:colbster} (~/cs/736)% cd cs736-p2 {alfred:colbster} (~/cs/736/cs736-p2)% mkdir doc src {alfred:colbster} (~/cs/736/cs736-p2)% touch README Makefile Notes {alfred:colbster} (~/cs/736/cs736-p2)% cvs import cs736-p2 r97-10-12 r97-10-12 CVS looks at all the files in the current directory tree, and imports them into a new project called cs736-p2. The occurances of r97-10-12 are labels for the vendor-tag and release-tags. (See 'man cvs'). Now Colby gives his cs736-p2 group write permission to the CVS repository. {alfred:colbster} (~)% cd CVS {alfred:colbster} (~/CVS)% ls -l drwxr-xr-x 2 colbster 2048 Oct 12 15:59 CVSROOT drwxrwxr-x 4 colbster 2048 Oct 12 16:07 cs736-p2 First, create an AFS group to represent cs736-p2 users: {alfred:colbster} (~/CVS)% pts creategroup colbster:cs736-p2 {alfred:colbster} (~/CVS)% foreach U (colbster alexey suan) foreach: pts adduser $U colbster:cs736-p2 foreach: end {alfred:colbster} (~/CVS)% pts membership colbster:cs736-p2 Members of colbster:cs736-p2 (id: -1056) are: suan colbster alexey Now Colby sets the ACL (permission) for the CVS directories: {alfred:colbster} (~/CVS)% fs setacl . system:anyuser read {alfred:colbster} (~/CVS)% fs setacl CVSROOT colbster:cs736-p2 write {alfred:colbster} (~/CVS)% fs setacl cs736-p2 colbster:cs736-p2 write Now each user in the cs736-p2 group can create each of their working directories: Do one of two things: ------------------------------------- 1) Add the following to your .cshrc.local file: setenv CVSROOT /u/c/o/colbster/CVS 2) Every time you run a 'cvs ...' command, you must specify cvs -d ~colbster/CVS ... Colby now creates his own working directory, as well Alexey and Suan -------------------------------------------------------------------- {alfred:colbster} (~)% {alfred:colbster} (~)% cd cs/736 {alfred:colbster} (~/cs/736)% cvs checkout cs736-p2 This will create your cs736-p2 working directory, which only you have access to. CVS always knowns where the main repository is because of your CVSROOT env variable, or because you always use 'cvs -d ~colbster/CVS ...' =============== To Add a File =============== Suan is going to add the proposal.html file to the project. To do that, he would do: {siamese:suan} (~)% cd cs/736/cs736-p2 {siamese:suan} (~/cs/736/cs736-p2)% ls -l drwxr-xr-x 2 colbster 2048 Oct 12 16:07 CVS -rw-r--r-- 1 colbster 0 Oct 12 16:07 Makefile -rw-r--r-- 1 colbster 0 Oct 12 16:07 Notes -rw-r--r-- 1 colbster 0 Oct 12 16:07 README drwxr-xr-x 3 colbster 2048 Oct 12 16:07 doc drwxr-xr-x 3 colbster 2048 Oct 12 16:07 src {siamese:suan} (cs/736/cs736-p2)% cd doc {siamese:suan} (cs/736/cs736-p2/doc)% mv ......../proposal.html . {siamese:suan} (cs/736/cs736-p2/doc)% cvs add proposal.html The proposal.html file has been marked to be added at the next 'cvs commit'. =================== To Commit Changes =================== If Suan just wishes to commit the added proposal.html file: {siamese:suan} (~/cs/736/cs736-p2/doc)% cvs commit proposal.html Or if Suan wants to commit all files recursively, starting from the current working directory: {siamese:suan} (~/cs/736/cs736-p2/doc)% cvs commit When Suan commits files, every one of those files most be up to date. If they aren't, CVS will refuse to commit the files. Suan can remedy this by updating them with 'cvs update'. ==================== Get a fresh Update ==================== Suppose Alexey wants to get fresh copies of all the code, namely Suan's proposal.html file. If he hasn't yet checked out the project: {derby:alexey} (~)% cd cs/736 {derby:alexey} (~/cs/736)% cvs checkout cs736-p2 {derby:alexey} (~/cs/736)% cd cs736-p2 If he HAS checked out the project, and just wants the updated files: {derby:alexey} (~)% cd cs/736/cs736-p2 {derby:alexey} (~/cs/736/cs736-p2)% cvs update ====================== General Instructions ====================== You always have write access to your working files. You can 'cvs add filename' or 'cvs remove filename' at anytime, however other users won't be affected until you 'cvs commit'. A file MUST be up-to-date BEFORE you can 'cvs commit' the file. So if Suan wants to 'cvs commit proposal.html', but Alexey does it first, then Suan must first do 'cvs update proposal.html'. If there are any conflicts, Suan must resolve them, by editing the file, and fixing the conflicts (which appear as diff output within the file). Then he can do 'cvs commit proposal.html'. ====================== Export a Version ====================== When it comes time to turn in an image of the project to the professor, the 'cvs export' command is very effective. 'cvs export' works much like 'cvs checkout', except that CVS files are not created, only an image of the latest version (or whichever version you select). First, a current image must be given a version number, or tag as CVS calls it. Suppose Colby wishes to turn in the latest version of the project. First, he will commit any last changes. {alfred:colbster} (~/cs/736/cs736-p2)% cvs commit {alfred:colbster} (~/cs/736/cs736-p2)% cvs tag r97-10-12 This will tag all files with the version 'r97-10-12'. Many version naming conventions can be used, so long as they begin with a letter. Now the repository contains the latest and greatest files, tagged with a version number, in this case, the date of the version. The repository is ready to emit an export of this version. Colby goes to his handin directory: {alfred:colbster} (~)% cd /p/course/cs736-cao/handin/colbster He can now 'export' an image of the latest files {alfred:colbster} (/p/course/cs736-cao/handin/colbster)% cvs export -r r97-10-12 cs736-p2 This will create the cs736-p2 directory tree, with all the files tagged with r97-10-12. To save disk space, Colby can tar and gzip the directory into a compact archive: {alfred:colbster} (/p/course/cs736-cao/handin/colbster)% tar -cf - cs736-p2 | gzip > cs736-p2-97-10-10.tar.gz {alfred:colbster} (/p/course/cs736-cao/handin/colbster)% \rm -fr cs736-p2 {alfred:colbster} (/p/course/cs736-cao/handin/colbster)% ls -l total 5 -rw-r--r-- 1 colbster 191 Oct 12 17:13 cs736-p2-97-10-12.tar.gz ============= Conclusions ============= This document hopefully gave you some momentum in getting started with CVS version control system. The CVS manual pages are very well written, and should provide information on CVS in much greater detail than this tutorial provides. Happy Version Control ----------------------- Colby O'Donnell colbster (at) cs (dot) wisc (dot) edu