Version Control 101 With CVS

To get started, here’s a quick definition of CVS from

“The Concurrent Versions System (CVS) keeps track of all work and all changes in a set of files, typically the implementation of a software project, and allows several (potentially widely separated) developers to collaborate.”

How can version control make your job as a web developer easier? Well, version control adds a small amount of time to your day-to-day activities, however if you are planning on working on a web site or product for more then a week, or want multiple people to be able to work on the same code at the same time, then version control systems can make things much easier in the long run. In this article we will be focusing on getting started with CVS on Windows using a free CVS program called Tortoise CVS.
You aren’t going to want to use CVS for everything, but anything that is going to last more than about a week and whose changes are mainly plain text are going to benefit from being version controlled. Why mainly plain text? Well, one of the most useful features of CVS is being able to compare changes between 2 versions of a file. This works best with plain text files like html, css, javascript, php, asp etc.


To get the latest version of Tortoise CVS head on over to and download the stable version which is under 6 MB in size.


Run the installer and choose the defaults for everything (i.e. Just keep clicking next) unless you want to install it in a different directory. You will have to reboot afterwards unfortunately to finish the installation so make sure you arn’t in the middle of something that would stop you from rebooting.

Preparing for CVS

Once you have rebooted and assuming you already have a website you want to store in CVS (this is usually called importing a module into CVS) then all you need to do is pick a directory to save all the cvs code to. You won’t have to do anything to this directory just make sure it exists and is empty. For this guide I will be using d:\cvs as my directory (from now on we will call this our cvs repository or just our repository).
Assuming that your website is in the directory d:\website, right click on the directory in Windows explorer and choose “Make New Module” as show in Figure 1:

You will be prompted with a window that asks you about where you would like to make the new module (i.e. which repository). Assuming your repository is like mine (just a folder on your hard drive), then choose “Locally Mounted Folder” from the protocol list. Doing this should add :local: to the CVSROOT field. Don’t worry about this field, we shouldn’t have to edit it manually.

Next, fill out the “Repository Folder” field. In our case this is d:\cvs. Finally we can specify a different name for the module if we like. In this case I am going to leave it as the name of the folder the files were in (i.e. Website) however it is a good idea to set this to your product name if you make software products or if you do more client focussed development then perhaps the client name would be a good choice of module.

Once these settings are filled in, click the OK button. Since this is your first time importing a module, the d:\cvs directory hasn’t been setup as a CVS repository yet. Thats OK, because we are now prompted to initialize a new repository. Check the tick box then click ok:

Once you click OK you should see a log window come up with a bunch of messages. The messages will differ depending on your exact situation but the main thing to look for is “Success, CVS operation completed” like in Figure 4:

You may also get a message about cvslock from Windows, in which case you should click on the “Unblock” button.

If you browse to your CVS directory in Windows explorer it will now show extra icons indicating the state of the files in CVS:

The question marks in our example indicated that CVS doesn’t know about these files for the module that you are looking at. The reason the CVS folder doesn’t have an icon is because it is a special folder which holds information about the CVS state of the files and directories at the current level. It’s a hidden folder so if you have Windows setup to hide hidden files (as is the default) then you won’t be able to see the CVS folder – which is fine.
Now that we have initialised our repository and created a module, we need to add the files to the module. This is really easy to do. Just right click on the folder you added to CVS add choose “CVS Add Contents” from the menu.

This will bring up a window which lets you choose which files you what you want to add to your module:


Now there is one step here that may confuse some people because it may seem a little strange until you get used to it. Adding a file does not automatically add it to CVS. If you browse to the file in explorer now, you will see the orange plus icon on it.

When a file is totally up to date in our repository though, it shows a green tick icon. So, to put the files into CVS we have to save the changes to the repository, otherwise known as commiting the changes. A change could be adding a file, removing a file or just modifying the file and they all have to be committed to have the change saved to the repository.

One point of interest though is that directories are automatically added to the CVS repository when you add them.

To commit the changes, right click in the folder and choose CVS Commit from the menu:

This will bring up a screen which lets you type in a message describing the commit. It may seem easier to not type a message here, but if you are coming back in a years time and trying to work out why you made a change then having a clear and concise commit message can save you having to spend a lot of time trying to work out what you were trying to do with a particular change or where you fixed a specific problem.

Even if your comment seems self explanitory now, it’s good to get into the habbit of always adding a comment when you commit. Once you are happy with your comment, click OK and you will get the familiar messages box that should tell you that the operation was completed successfully.

CVS lets you do some cool things like working on multiple copies of the same thing, which could be handy if you were working on something like getting a site functioning with different web servers and needed to install a copy for each web server. Using CVS, you can make changes to each copy, and, provided the parts that you are changing arn’t in the same part of the same file in both directories, you can do a “CVS Update” to merge the changes from one into the other and visa versa (after commiting them of course). You can even do this with different parts of the same file.

Another handy feature is being able to view the changes you have made since the version in the repository before commiting the change. This lets you pick up things like debugging code before it gets saved in the repository, helping you to keep a cleaner code base and if you do find some code in there that shouldn’t be, you can use the annotate feature to work out when it was put in (and who to blame).

This guide is only intended to get you started with CVS. The day-to-day overhead added from using CVS is simply running update and commit functions, which, considering you can track the full history of your files as you change them and as your site/program grows and can have multiple people working on the same file at the same time, is definetly worth it in the long run!

This entry was posted in Programming, Web Design, Web Technologies. Bookmark the permalink.

3 Responses to “Version Control 101 With CVS”

  1. Gavin Fawcett says:

    A good explanation of a piece of software I never knew existed . . . I've been using .rtf files to track changes to software builds, I never even knew CVS software existed! The time this is going to save me . . . thanks!!

  2. E G Neve says:

    This was a great article, and VERY TIMELY for me. Question: If I install this on my Windows 2003 Web Server Box, does it provide the ability for my hosting customers doing web design to use CVS? I have a customer who has aksed me for my server to support "cvs programming language" and I am not sure exactly what to put on my server to meet this request. ANY HELP YOU CAN PROVIDE IS APPRECIATED!

    [Editors note: Yes it will be able to be used by your customers as well, they just need to download the CVS app to their PC's too]

  3. Azizur Rahman says:

    Excellent article… Wish I knew this before!

Leave a Reply