You are on page 1of 6

Introduction to CVS with TortoiseCVS

CVS, or the Concurrent Versioning System, is a version control system. Version


control systems are generally used as part of the software development cycle to track
and co-ordinate source code changes among a team of developers.

For example, bugs sometimes creep in when software is modified, and you might not
detect the bug until a long time after you make the modification. With CVS, you can
easily retrieve old versions to see exactly which change caused the bug.

CVS also helps you if you are part of a group of people working on the same project.
It is easy to overwrite each others' changes unless you are extremely careful. CVS
solves this problem by insulating the different developers from each other. Every
developer works in his own sandbox, and CVS merges the work when each developer
is done.

To use CVS within a unix environment requires learning some Unix commands. Here
is a short tutorial if you wish to use Unix: https://www.cvshome.org/docs/blandy.html

The instructions below show how to use CVS with a Windows environment using a
free client called TortoiseCVS.

1. Initialize your CVS environment - only necessary once

This should only be done once. If you are sharing a project with other members of
your group, then only one person needs to do this.

1. Log into bigmazzy.math.uaa.alaska.edu


2. Create a directory to store your cvsfiles, named "cvsroot" with
the command
mkdir ~/cvsroot
3. Set the environment variable CVSROOT to this directory with
the commands
CVSROOT=~/cvsroot
export CVSROOT
4. Set permissions so anyone can access this folder (or more
restrictive permissions if you have a group set up):
chmod 777 ~/cvsroot
5. Execute the following command to initialize cvs, it will put a
directory in your cvsroot folder:
cvs init

2. Install TortoiseCVS - only necessary once per client

Just download and install the program which is available at


http://tortoisecvs.sourceforge.net/
3. Create a new Module - only necessary once per project

TortoiseCVS integrates itself into the Windows Explorer. Fire up a new explorer. To
create a new, empty project, first create a folder to hold the files. In this example, I
made a folder called "SampleProject" off of the C:\ drive:

Next, right-click on the SampleProject to bring up the CVS menu. CVS uses
"modules" to describe projects. Make a new module by selecting the New Module
option:

Fill out the new module screen by selecting secure shell as the protocol. Put the path
to your repository folder and use your username (instead of afkjm as shown below).
Also give a name to your module. In this case, I called it "SampleProject":
When you click OK you will be prompted (a couple of times) to enter your password.
If all succeeds, you have now registered this project with CVS on bigmazzy as well as
with TortoiseCVS on your local machine.

If the project "SampleProject" already was created on bigmazzy, then this process will
also download any files that may exist on the server to the local machine. This is the
same as a "checkout". You could perform this task separately, but TortoiseCVS will
perform a checkout for you when you initially make the module.

4. Update Files - should do before you make any changes

To incorporate changes done by others in your local working copy use the "update"
option. Updating may be done on single files, a set of selected files, or recursively on
entire folder hierarchies. To update, highlight the files and/or folders you want, right-
click and select CVS Update.

In the figure below, I am updating everything in the SampleProject directory.


5. Adding or Updating Files - done after updating

To add a new file simply place it into the project folder. In the picture below I have
added two new files to the SampleProject directory (TortoiseCVS created the CVS
folder):

The question mark indicates that these files are not stored in CVS. To make them part
of CVS, select them, right-click, and then choose "CVS Add"
TortoiseCVS will ask for your password and then put the files into CVS. They will
show up as red icons:

The red icons mean that the file has been modified compared to what is stored in the
CVS repository. The icons would also change to red if you had modified files that
you have updated. To store the changes made in your files to CVS, select them, right-
click, and then use CVS Commit:

You'll be prompted to enter a comment. Enter some information about the changes
that you just made. Then you'll have to enter your password again. When done, CVS
will change the file icons to green to indicate that the files on your local sandbox are
up to date with the files you last downloaded from the CVS repository:

6. Modifying Files

To work on a file, it is a good idea to first perform an update so you get a copy of the
latest files. Then, simply modify the file as needed. You'll notice that the icon will
change colors to red for the files you work on. In the example below, I have changed
the contents of readme.txt:
To upload your changes to CVS, simply right-click on the file(s) and select CVS
Commit. The changes will be uploaded to the CVS server.

7. Resolving Conflicts

It is possible that when you go to upload your changes, someone else has made
changes to the file and uploaded them in the interim. When this happens, a conflict
occurs. As CVS knows nothing of your project, it leaves resolving the conflicts to the
developers. Whenever a conflict is reported, you should open the file in question, and
search for lines starting with the string <<<<<<<.

The conflicting area is marked like this:

<<<<<<< filename
your changes
=======
code merged from repository
>>>>>>> revision

You must decide what the code should look like, do the necessary changes, remove
the CVS markup, and commit your modifications to the repository.

8. Reverting to an old file version

Developers occasionally need to undo changes that have already been checked in.
Going back to a specific file revision in TortoiseCVS is easy:

1. Right-click on the file and select CVS --> History to bring up the
History Dialog
2. Right-click on the revision you need and choose the "Save this revision
as..." option.
3. When the Save As dialog appears, do not click the "Save" button;
instead, double-click on the file's name in the directory listing.
4. Answer "Yes" when TortoiseCVS prompts you to overwrite the file.

You might also like