CVS Intro Compiled by Michael Wang (xw73@columbia.edu) Last updated 2007-02-23 * VCS Administration ** How to set up a repository? export CVSROOT=/some/dir/newrepos cvs init One can use ``-d /some/dir/newrepos'' if the environment variable is not set, but it is easier to set up CVSROOT once instead typing the ``-d'' option over and over again. ** How to import a new project? Goto the root of your new project, ie. myproj: cd myproj cvs import -m "initial import" myproj mycom start Note: - keep only those files you want to put under CVS control, and Clean out all other files from this directory; - never put the ``repository'' under the dictory of your new project; ** How to set up write permission? - Add a unix group and add writers to the group. - cd /my/repository - chgrp -R . - chmod ug+rwx . CVSROOT See Fogel P98. ** How to set up remote CVS connection? Use SSH export CVSROOT=:ext:@: export CVS_RSH=ssh Or use the following procedure: - Edit /etc/inetd.conf, cvspserver stream tcp nowait root /usr/local/bin/cvs cvs --allow-root=/my/repository pserver} - Edit /etc/services, cvspserver 2401/tcp - Setup $CVSROOT/CVSROOT/passwd in the format of: user:encripted passwd as in /etc/shadow - Edit HUP the inetd process typeset -x CVSROOT=:pserver::/my/repository on CVS client - touch ~/.cvspass - cvs login * CVS Usage ** How to check out a working copy of the repository? After import, you may check out a working copy of your project anywhere. cd /this/directory cvs checkout myproj ** How to check out a working copy of a new prog in the repository? cd /this/directory cvs checkout myproj/newdir/newprog ** How to find the difference - between working copy and base copy, - between working copy and repository copy, - between base copy and repository copy, and - between two versions in repository? To find the difference between working copy and base copy (last "checkout", "update" or "commit"), cvs diff To find the difference between working copy and repository copy, cvs diff -r HEAD To find the difference between base copy and repository copy, cvs diff -r BASE -r HEAD To find the difference between two versions, cvs diff -c -r version1 -r version2 Note: cvs diff also shares some options with GNU command line diff, eg -c. ** How do I ``update'' my copy with a repository copy? By default, ``update'' will bring the updated version in repository to your working copy. cvs update filename You can use ``update'' to dismiss the later modification on your project, and revert to an earlier version. For example, after using "cvs log" and "cvs diff", you decide to get rid of current version 1.6, and change back to version 1.4, you can use, cvs -Q update -p -r 1.4 filename > filename Where -Q means quiet mode, however the noise goes to stderr and will not be directed to a file. This option is not mandatory. -p means to send the file content to standard output. If the filename is in a subdirectory which does not exist in your working directory, use ``-d'' option, cvs update -d filename This will bring over both the directory and the filename under the directory. ** How do I commit a change? After you modified a file and want to send the changes to repository, please use: cvs commit filenames ** How to check the status of a working copy? cvs status filenames ** How to finding out who did what (browsing log messages)? cvs log filenames ** How to add new files? Two steps to add a new file to your repository: add and commit. cvs add new_files cvs commit -m "added new files" new_files ** How to add directorories? One step to add new directories: add. mkdir newdir cvs add newdir ** How to removing files? rm oldfile cvs remove oldfile cvs commit -m "remove oldfile" oldfile ** How to removing directories? /* Suppose olddir with 2 files inside the directory * is the directory to be removed from repository. */ cd olddir rm oldfile1 oldfile2 cd .. cvs remove olddir # scheduling olddir/oldfile[12] for removal cvs commit olddir # remove these files permanently cvs update -P olddir # remove empty dir from working dir /* * cvs update -d olddir # to bring back the empty dir */ /* Alternatively: * * cd olddir * rm oldfile1 oldfile2 * cvs remove oldfile1 oldfile2 * cvs commit oldfile1 oldfile2 # have to remember the file names * cd .. * cvs update -P olddir */ ** How to renaming files and directories? mv oldname newname cvs remove oldname cvs add newname cvs ci -m "mv old to new name" oldname newname mkdir newdir cvs add newdir mv olddir/oldfile1 olddir/oldfile2 newdir cd olddir cvs rm oldfile1 oldfile2 cd ../newdir cvs add oldfile1 oldfile2 cd .. cvs commit -m "mv old files to newdir" cvs update -P olddir newdir References: Bar, Moshe, and Karl Fogel, Open Source Development with CVS. 3rd ed. Arizona: Paraglyph Press, 2003. .