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 www.testing.com 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 www.testing.com 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 www.testing.com 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” www.testing.com Garry Start

In English, this says “import everything in this directory into CVS, give it a module name of www.testing.com, 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:


Macintosh:www.testing.com garry$ cvs import -m "Initial Import" www.testing.com Garry Start
N www.testing.com/.DS_Store
N www.testing.com/index.html
cvs import: Importing /Users/garry/Documents/cvsrep/www.testing.com/images
N www.testing.com/images/Picture2.png

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


Macintosh:www.testing.com garry$ cvs rls
cvs rls: Listing module: `.'
CVSROOT
drupal5.3
www.example.com
local.devsite.com
www.testing.com

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

#cvs rls www.testing.com


Macintosh:www.testing.com garry$ cvs rls www.testing.com
cvs rls: Listing module: `www.testing.com'
.DS_Store
index.html
images

Now our project is in CVS, we can delete the www.testing.com 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 www.testing.com


Macintosh:htdocs garry$ cvs checkout www.testing.com
cvs checkout: Updating www.testing.com
U www.testing.com/.DS_Store
U www.testing.com/index.html
cvs checkout: Updating www.testing.com/images
U www.testing.com/images/Picture2.png

Now, a quick 'ls' should reveal the newly added www.testing.com 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 www.testing.com
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: 

Leave a Reply

Your email address will not be published. Required fields are marked *