
Table of Contents
First, configure your environment (we will assume csh/tcsh). To set the editor that will be used to create CVS log messages:
$ setenv CVSEDITOR viTo enable ssh for remote transfers:
$ setenv CVS_RSH sshYou may optionally set a default repository. To set a local repository as the default:
$ setenv CVSROOT "/home/userid/cvs"
To set a remote repository as the default:
$ setenv CVSROOT ":ext:userid@cvs.cs.clemson.edu:/home/userid/cvs"
Note: For the remainder of this section, it is assumed that you have the CVSROOT environment variable set. If you choose not to set this variable, please replace 'cvs' with 'cvs -d /home/userid/cvs' for the remainder of this tutorial.
First, initialize the repository:
$ cvs initNext, create the initial project (skip if project exists):
$ cd /home/userid
$ mkdir cpscXXX
$ cd cpscXXX
$ mkdir lab1
$ touch lab1/Makefile
$ mkdir lab2
Now we are ready to import the project:
$ cvs import -m "Importing project cpscXXX for userid" cpscXXX userid start cvs import: Importing /home/userid/cvs/cpscXXX/lab1 N cpscXXX/lab1/Makefile N cpscXXX/lab1/main.c cvs import: Importing /home/userid/cvs/cpscXXX/lab2 No conflicts created by this importYou may now safely delete/move the original project directory, because the project can be checked out from CVS:
$ cd /home/userid
$ rm -fr cpscXXX
$ cvs checkout cpscXXX
cvs checkout: Updating cpscXXX
cvs checkout: Updating cpscXXX/lab1
U cpscXXX/lab1/Makefile
U cpscXXX/lab1/main.c
cvs checkout: Updating cpscXXX/lab2
$ cd cpscXXX
Note: You may import an unrestricted number of projects into a repository.
Now that our project has been check out, we are free to make changes to it. Once you have made your changes, you must commit them to the repository. Each time you commit to the repository, CVS will prompt you to enter a log message that describes the changes. You may supply the message using the -m flag; if you do not supply a message at the command line, CVS will open an instance of CVSEDITOR. To commit a change:
$ cvs commit -m "Changed stuff"
cvs commit: Examining .
cvs commit: Examining lab1
cvs commit: Examining lab2
Checking in lab1/Makefile;
/home/userid/cvs/cpscXXX/lab1/Makefile,v <-- Makefile
new revision: 1.2; previous revision: 1.1
done
Eventually, you will want to add files to your project:
$ cd /home/userid/cpscXXX/lab1 $ touch draw.c $ cvs add draw.c cvs add: scheduling file `draw.c' for addition cvs add: use 'cvs commit' to add this file permanently $ cvs commit -m "Added draw.c" cvs commit: Examining . RCS file: /home/userid/cvs/cpscXXX/lab1/draw.c,v done Checking in draw.c; /home/userid/cvs/cpscXXX/lab1/draw.c,v <-- draw.c initial revision: 1.1 doneYou will likely want to remove files as well:
$ cd /home/userid/cpscXXX/lab1
$ rm main.c
$ cvs remove main.c
cvs remove: scheduling `main.c' for removal
cvs remove: use 'cvs commit' to remove this file permanently
$ cvs commit -m "Removed main.c"
cvs commit: Examining .
Removing main.c;
/home/nkraft/cvs/cpscXXX/lab1/main.c,v <-- main.c
new revision: delete; previous revision: 1.1.1.1
done
Before you commit your changes, you'll need to have the latest version of the project. If other users are simultaneously updating your project, you must keep your local version in sync with the repository. To update your workspace:
$ cd /home/userid/cpscXXX/lab1
$ cvs update
cvs update: Updating .
U Makefile
To restore a project to its state at a given date and time in the past, use the -D flag:
$ cd /home/userid/tmp
$ cvs checkout -D "2006-04-20 16:20" cpscXXX
cvs checkout: Updating cpscXXX
...
Branches allow you to maintain seperate versions of a projects, e.g. a stable version, a testing version, and an unstable version. You create branches with the -b flag:
$ cd /home/userid/cpscXXX
$ cvs tab -b stable
cvs tag: Tagging .
cvs tag: Tagging lab1
T lab1/Makefile
T lab1/draw.c
cvs tag: Tagging lab2
After tagging the project, you must release the current working directory
and checkout a fresh copy of the project (now specifying the branch name):
$ cd /home/userid
$ cvs release -d cpscXXX
You have [0] altered files in this repository.
Are you sure you want to release (and delete) directory `cpscXXX': y
$ cvs checkout -r stable cpscXXX
cvs checkout: Updating cpscXXX
cvs checkout: Updating cpscXXX/lab1
U cpscXXX/lab1/Makefile
U cpscXXX/lab1/draw.c
cvs checkout: Updating cpscXXX/lab2
To do its job, CVS adds many auxilary files to your workspace. To obtain a copy of the project without these added files:
$ cd /home/userid/public_html
$ cvs export -D "now" cpscXXX
cvs export: Updating cpscXXX
cvs export: Updating cpscXXX/lab1
U cpscXXX/lab1/Makefile
U cpscXXX/lab1/draw.c
cvs export: Updating cpscXXX/lab2