Once you decide where you want your repository to be, you should point the CVSROOT environment variable to the repository location. For example:
setenv CVSROOT
/mit/asksipb/cvstest
After doing so, typing cvs init
will set up an empty
repository. (You can also use the -d
option to specify a
repository location instead of using CVSROOT, but CVSROOT is usually
easier.)
Each CVS repository can have several projects. Now that your repository is ready, you can either import an existing directory structure or start from scratch.
To import an existing directory structure, cd
to the
directory, and type:
cvs import -m "imported directory" projectname
vendortag releasetag
projectname controls where the project is stored in the
repository. vendortag and releasetag aren't
particularly important, but are still required. Your username for
vendortag and start
for releasetag would be
reasonable defaults.
To start from scratch, create an empty project directory, and then follow the steps above.
To check out a project, you use the cvs checkout
command. As before, you either need to have CVSROOT defined, or use
the -d
option to specify the location of your repository.
cvs checkout projectname
After checking out a project, a subdirectory with the same name as the project you checked out will be made in your current working directory. It will contain all of the files in the project, and you can edit them at your leisure.
cvs commit
command, or
cvs ci
for short. For example:
cvs ci -m "Fixed a typo" intro.html
When you specify a filename, you check in that file specifically. If
no file is specified, you are checking in all of the files of the
project that you have modified. The -m
flag allows you to
add a message to your commit. If -m
is not specified, CVS
will invoke the editor pointed to in the CVSEDITOR
environment variable, and ask you to type in a message.
If you are not using the most up to date version of the file, CVS will
not check in the file. You will need to run cvs update
as described below before reattempting the checkin.
cvs add filename
This marks the file as a new file to be added. It is, however, not
immediately added to the repository. To actually add it, you will
also need to run:
cvs commit
cvs update
command, or cvs up
for short.
You may want to consider using the -d
option when you use
cvs update
. This will ensure all directories in the
repository are also in your local copy, even if some directories were
added to the repository after you initially checked it out. The
-P
option is also useful, as it will prune empty
directories from your local copy. CVS does not provide a way to
remove old directories, which is why this option can be necessary.
After a cvs update
, you will have the most up-to-date
copy of the files in the repository. If other people have made
changes to the same file that you have been working on, their changes
will be merged into your local copy. If these changes conflict, CVS
will mark the differences with the lines "<<<<<<<", "=======" and
">>>>>>>". Look over the changes made, fix things as necessary,
and remove the line markers.
cvs diff
command,
with your filename as an argument. Without an argument, a
diff
will be performed on all of the modified files in
your project. This is similar to rcsdiff
in RCS.
Similarly, the cvs log
command will show you what changes
have been made to a particular file, like rlog
does in
RCS.
C-x v v
. When checking in a file, Emacs will open a
buffer prompting you to enter a change comment. After entering your
comment, C-c C-c will end your comment and check in the file.