CVS Repository Creation
How to set up a personal CVS repository
- Set the CVS_RSH variable to 'ssh':
setenv CVS_RSH ssh
- Determine where you want you cvs repository to live. For
example, you might want it to live in
/student/abc123/mycvs (where abc123 is
replaced with your own NSID, of course).
- Initialize the repository with:
cvs -d somemachine:/student/abc123/mycvs/root init
where somemachine is replaced with the name of any
computer that you can login to and where /student/abc123
is available (e.g. any of the stealth machines.
- Now that the repository is set up, the next step is to add a
project (or 'module') to the repository. Here we consider adding a
project called
cribbage which happens to live
in a directory called cribbage, and which consists of the
following files:
total 47
-rw-r--r-- 1 abc123 student 104 Dec 12 08:56 Makefile
-rw-r--r-- 1 abc123 student 608 Dec 12 08:56 README
-rw-r--r-- 1 abc123 student 45352 Dec 12 08:56 cribbage.c
The correct way to import this project is to do the following two commands:
cd ..../cribbage
cvs -d somemachine:/student/abc123/mycvs/root import -m "Initial import of my cribbage project" cribbage vtag rtag
This will create a module called cribbage.
It is not necessary to have all (or any!) project files present when a
module is created. It is sufficient to only have the main project
directory. For example:
mkdir myproject
cd myproject
cvs -d somemachine:/student/abc123/mycvs/root import -m "Initial import of myproject" myproject vtag rtag
is all that is needed to make an empty project named myproject.
- Now that the project exists in the repository it can be "checked
out" to any location. E.g.
cvs -d stealth10:/student/abc123/mycvs/root checkout cribbage
- Once a project has been checked out you can then proceed to make
changes to the checked-out copy. To add a file called
TODO to the cribbage repository:
cd cribbage
cp /student/abc123/TODO .
cvs add TODO
cvs commit -m "Initial commit" TODO
If you have a line that contains the string:
$Id$
anywhere in your file, then that string will get expanded to something like:
$Id: TODO,v 1.1 2006/11/29 11:16:58 abc123 Exp $
after the initial import. Each time you check-in or check-out a
revision, the version of the file will be displayed in this line.
When doing the cvs commit, the -m "Initial
commit" is the message to associate with the commit. If you
don't specify this, then your favorite editor will be fired up, and
you'll be asked to provide a comment on the changes being checked in.
- You are not limited to a single checkout -- all or part of a
particular project can be checked out. E.g.:
cd /tmp
cvs -d stealth10:/student/abc123/mycvs/root co cribbage
Note that this pulls out the entire contents of the module 'cribbage'.
If we just wanted the one file, we could do:
cvs -d stealth10:/student/abc123/mycvs/root co cribbage/TODO
Once you are working inside the module directory (where CVS
directories exist) there is no need to specify the repository being
used.
- Edit the file and check it back in:
cd cribbage
vi TODO
# make some changes
cvs ci TODO # (or 'cvs commit TODO')
observe that the $Id$ line is now something like:
$Id: TODO,v 1.2 2006/11/29 11:23:19 abc123 Exp $
- If you're collaborating on a project with others, you will need to
update your local files to incorporate any of the changes others have
made. This command is run inside the already checked-out project directory:
cvs -d stealth10:/student/abc123/mycvs/root -q update -dPA
The '-q' says to do this job quietly, and the
'-dPA' is needed to make
sure that new directories and removed files/directories get dealt with
correctly.
- Other useful commands:
cvs history scan.pl # see who's changed the file recently.
cvs annotate scan.pl # see who modified what lines, and when.
# Also known as 'cvs blame' in some circles :)
# show a regular 'diff' between revisions 1.1 and 1.2
cvs diff -r 1.1 -r 1.2 scan.pl
# show a context 'diff' between revisions 1.1 and 1.2
cvs diff -c -r 1.1 -r 1.2 scan.pl
- One can also get fancy and add tags, branches, and a bunch of other
things. See '
man cvs' for more information, and/or consult
your favorite web-resource for more information on cvs.
How to create a shared CVS repository
- There are a couple of ways to share a repository. Both ways
require all repository users to be in the same Unix group.
- Use ``security by obscurity'' and rely on a hidden directory
whos name is known only to the members of the group.
- Ask your friendly neighbourhood techstaff member for a special
group.
In the first case, the procedure is to create a hidden directory for
the repository. For example:
mkdir /student/abc123/hidden
chmod 711 /student/abc123/hidden
mkdir /student/abc123/hidden/abcd1234
chgrp student /student/abc123/hidden/abcd1234
chmod 770 /student/abc123/hidden/abcd1234
chmod g+s /student/abc123/hidden/abcd1234
Note that these directories will be created with your default group
and that you will want to chgrp them to a group that all
users share (e.g. student). As well, the only
``security'' here is that only users who know the full path to the
repository will be able to read or modify the files. The repository
path will then be somemachine:/student/abc123/hidden/abcd1234.
In the second case, you will be assigned a group name similar to
stgr0001. The setup for the directories can be simply:
mkdir /student/abc123/mycvs
chgrp stgr0001 /student/abc123/mycvs
chmod 770 /student/abc123/mycvs
chmod g+s /student/abc123/mycvs
and the repository path will be just
somemachine:/student/abc123/mycvs.
- Initialization of the repository is done as in the previous
section with the
cvs init command.
- Setup directory permissions according to who will be using the
repository. For example, if members of group
stgr0001
are to have access to the repository, then perform the following:
chgrp -R stgr0001 /student/abc123/mycvs/root
find /student/abc123/mycvs/root -type d -exec chmod g+s {} \;
This will allow anyone in group stgr0001 to access and
change files in the repository.
- Following the previous example, after the initial import of the
module
cribbage, it will likely be necessary to make sure that
the permissions on the new module are set properly. For group
stgr0001 the following lines would take care of this:
chgrp -R stgr0001 /student/abc123/mycvs/root/cribbage
chmod g+s /student/abc123/mycvs/root/cribbage
- At this point all the normal cvs commands will work for all
members who have group permissions no the repository.
|