Adding Projects To CVS

Let's say you've got a website or a directory of code somewhere that you've finaly got around to putting into CVS. I keep having to do this, and I keep messing it up so here's a quick cheat sheet type run through.

This example is based on OSX and the command line version of CVS with a local repository.

Adding a project (module) to CVS

For the purposes of this example, I'm going to assume that you have a local directory called 'htdocs' in which you keep all your various web sites. So, it looks something like this:

Right, now let's say you have another web site called which you want to add to CVS, and to your local developement environment (in htdocs).

First of all, grab a copy of all the files that make up that website, and put them in a folder called on your desktop (or whichever location you prefer.) This is only a temporary folder as once the code is in CVS, we'll delete it.

Now, get a terminal session and make your way to the directory. (Otherwise known as cd'ing into that directory). Now we're going to add the contents of this directory to CVS.

#cvs import -m “Initial import” Garry Start

In English, this says “import everything in this directory into CVS, give it a module name of, my name is Garry, I want to label this import with 'Initial Import' and tag it with 'Start' “. Don't worry about the name and the tag bit for now.

You should now see CVS listing all the files it's importing, with a N at begining to show it's a New file: garry$ cvs import -m "Initial Import" Garry Start
cvs import: Importing /Users/garry/Documents/cvsrep/

No conflicts created by this import

If like me you're naturaly distrusting of computers, you can verify that your project is now in CVS by telling CVS to list all it's modules (projects):

#cvs rls garry$ cvs rls
cvs rls: Listing module: `.'

In there you should see To see what's in that particular module, specify the module name on the end of the rls command:

#cvs rls garry$ cvs rls
cvs rls: Listing module: `'

Now our project is in CVS, we can delete the folder from our desktop. (Or archive it if you prefer)

Checking out code to work on

In your terminal session, cd to the 'htdocs' directory where you want to actualy work on the code and we'll get a working copy from CVS

#cvs checkout

Macintosh:htdocs garry$ cvs checkout
cvs checkout: Updating
cvs checkout: Updating

Now, a quick 'ls' should reveal the newly added directory in your htdocs. Look inside it, and you should see a directory called CVS where CVS keeps its own stuff, along with our files.

Macintosh:htdocs garry$ ls -l
total 8
drwxr-xr-x 5 garry admin 170 Apr 6 18:16 CVS
drwxr-xr-x 4 garry admin 136 Apr 6 18:16 images
-rw-r--r-- 1 garry admin 195 Apr 6 18:05 index.html

Now we're good to go and work on the project files.

Article types: