Quicker Start to CVS

Brian Hargreaves

Okay! This is the page for those of you who really don't like to follow instructions.

By using it, you agree to buy me lunch if you ask any me questions that are explained on the other page of instructions....


1. Create a Repository

This creates the repository in a subdirectory called cvsroot:

cvs -d ~/cvsroot init

Now add a line to your .cshrc or .bashrc file that sets the environment variable CVSROOT to $HOME/cvsroot. This will tell CVS where your default repository is.

2. Add a Project to the Repository

We'll assume you are starting from scratch. If not, keep the files elsewhere and copy them in here later.

mkdir ~/cvsexample
cd ~/cvsexample
cvs import -m "dir structure" cvsexample yourname start

"yourname" and "start" are really unimportant - they are just version and "vendor" labels. "cvsexample" tells CVS to store the archive in a directory cvsexample. Also, when you checkout cvsexample later, it will create a directory called cvsexample.

Now you completely erase ~/cvsexample, because you're going to check it out as a CVS working directory:

cd ~
rm -r cvsexample

3. Check out a Project

This is the same for our example as it is for the case where another user checks out an existing project. Checking out a project in CVS will create a CVS working copy.

cd ~
cvs checkout cvsexample

Now you have a directory called cvsexample, which should have a subdirectory called CVS. (all directories under CVS control will have this subdirectory).

4. Adding files

Create a text file called sample.tex using your favourite editor. You then add the file using:

cd ~/cvsexample

cvs add sample.tex

You should get a message saying that CVS has added the file, but you should use CVS commit to permanently add them. Go ahead and commit them:

cvs commit -m "original file" sample.tex

If you omit the -m "original file" then cvs will start up your default editor for you to type a log message.

Adding directories works with cvs add too.

5. Working on the Project

Update is one of the most important CVS commands. It updates your working directory from the repository, but also tells you status of files. Try it:

cvs update

Now change sample.tex and run cvs update again. It puts an M next to sample.tex indicating that you modified it.

Let's look at what we've changed with cvs diff:

cvs diff sample.tex

CVS prints a nice summary of what you've changed compared with the repository version. Now check in the change to the repository:

cvs commit sample.tex

When you do this, CVS pops up an editor. Just type a line like "first changes to file" on the first line and save/exit the editor.

Notice that the revision number is now 1.2.

6. From Here

You really should learn about conflicts, log messages and tags if you are going to work on CVS projects with others. These are described on the other page.