CVS basics

From Netsoc Wiki
(Redirected from CVS Basics)
Jump to: navigation, search


This guide will take you through the basics of CVS. It is assumed that the repositry has already been setup correctly and you have access to it. The term code in this guide should be taken to mean source code, documents or whatever else you are managing via CVS.

If you've just been given access to the main website or the MUD, this is the document you want to read.

What is CVS?

CVS is the Concurrent Versioning System. Essentially it lets one or more people work on the same code, and keeps track of the different versions as they are produced. All this information is stored in a central repositry. In addition, each person has their own working area which is their personal copy of the latest version (usually) of the code and their changes.

Checking Out

The first thing you have to do is to create your working directory. You should only ever have to do this once for a given project. The command is

cvs -d /path/to/cvs/repositry checkout module_name

This would create a directory called module_name in the current directory with the latest version of the code.

The person in charge of the repositry should provide you with the path to the repositry and module name. For example:

cvs -d /var/cvs checkout netsoc_www    #Netsoc Website 
cvs -d /var/cvs checkout ldmud         #Netsoc MUD

Getting the Latest Version

As other people commit their changes to the repositry, your working copy will get out of date. To get the latest version run

cvs update -d

This will also create any new directories that have been added. You should update regularly and ensure that your changes work with the latest version.

It is possible that there'll be a conflict - this means that CVS wasn't able to merge your changes with the latest version. If this happens you'll have to manually fix it by editing the file.

Making Changes

Once you have a working copy of the repositry, you can make whatever changes you want without affecting anyone else. Once you are happy with your changes you should update your working copy as described above. Assuming that everything still works, you can check it in with

cvs commit

This will look through the current directory and its subdirectories for changes. It will ask you for a log message to go with your changes, make sure it's meaningful as you might be looking at it months later.

Adding and Removing Files

If you follow the above instructions, you'll notice that any new files you add are ignored. To add a file use

cvs add filename
cvs add -kb filename      #Add a binary file

Similarly, to remove a file use

cvs remove filename

but note that the file must not exist.

The next time you checkin, the files will be add to/removed from the repositry. Directories are added similary, but you can't remove them.

You now know enough of the basics to use CVS

Older Versions

One of CVS's advantages is that all the old versions are saved. If you want an older version, you first have to figure out which version you're looking for. One way would be to look at the logs by

cvs log

which will display the commit messages and assocaited versions. You can specify a filename to get the logs for just one file.

Let's say that you want version 1.12 of file.txt. To retrieve that you could use

cvs update -p -r 1.12 file.txt

which will send it to the standard output.


Many of the CVS commands can be made shorter. Some examples:

cvs add cvs ad
cvs checkout cvs co
cvs commit cvs ci
cvs remove cvs rm
cvs update cvs up

See Also