CVS
CVS is a system for keeping track of project files when you are
several people working on them. The files are stored in a CVS
repository, together with information about the changes made. The old
versions of the files are saved, so you can easily recover them. The files
are grouped into modules, you can create a module with the import command.
When you want to work on a file you download (check out) a local copy of the file. You work on the copy in your home dir, and when you are done, you upload the file including the changes by committing the file to the repository. If the file has been changed since you checked out you copy, you are not allowed to commit the file. Instead you can see the difference between your version and the new version of the file by using the command update.
Contents |
Note
Starting January 1st, 2007, a new CVS-server (repos.gbar.dtu.dk) is available.
The most important features of the new CVS-server are:
- You can create more than one repository, each with its own set of users (eg. one repository per course).
- It's a bit easier to give access to other users.
- Easy way of making backups of your repositories.
As mentioned, the new server is available at repos.gbar.dtu.dk.
CVS in the G-Bar
As a user in the G-Bar, you have the opportunity to get a repository. Use the interface located at repos.gbar.dtu.dk to create the account, usage of the interface is described there as well. When the repository has been created, you may either continue to work with the options provided by the cvs interface, or set it up from the command line (described in the section "CVS from the command line"). Remember to take note of the $CVSROOT (checkout string) information, which is listed when you've created the repository. the information about the server which it contains, is needed to access the cvs later.
Acccess to your cvs
You have a few options, when you want to use the newly created cvs for daily use. The G-Bar provides a graphical tool to work with the cvs (i.e. checkout, commit and update), which is called smartCVS. smartCVS may be started from the menu under the category options, or alternatively from the command line with the command "smartcvs". Should you prefer a text based approach, you may use the traditional cvs commands from the command line, in which case you should read the "CVS from the command line" section.
Using smartCVS
We're not going to cover the full usage of smartCVS here, as it's a fairly straight forward program to use if you understand CVS (and if you don't, you might want to use google to read up a bit first :-). One part of the program is especially relevant though, and that is the Repository Profiles, one of which you need to create to be able to access your new CVS repository. Project -> Repository Profiles -> add -> enter CVS location contains a textbox, where you should fill in the $CVSROOT information that you took note of earlier (it has the following syntax):
:pserver:USERNAME@cvs.gbar.dtu.dk:/home/cvs/LOGIN/REPOSITORY
If you copy paste the info into the pserver field, smartCVS will fill out all relevant info for you. Beyond this, default settings should normally be enough when you have to configure smartCVS for daily use.
CVS from the command line
Setting up $CVSROOT
The CVSROOT variable defines a path to your CVS repository, so the cvs client knows where to look. Most commonly a CVSROOT is remote and will be on the following form:
[:method:][[user][:password]@]hostname[:[port]]/path/to/repository
If you have a CVS account in the G-Bar, you should set your CVSROOT in one of the following ways, depending on your shell (BASH is standard in the G-Bar):
BASH:
export CVSROOT=:pserver:USERNAME@cvs.gbar.dtu.dk:/home/cvs/LOGIN/REPOSITORY
tcsh:
setenv CVSROOT :pserver:USERNAME@cvs.gbar.dtu.dk:/home/cvs/LOGIN/REPOSITORY
If it's your own CVS-repository, LOGIN will be the same as USERNAME.
You are now asked for a password. This is your standard databar password, if it is you own repository. If not, the password will be the one chosen by the owner of the repository, when adding you to the repository. For adding user to a CVS-repository see the description below.
You have to run
cvs login
before you can access the CVS-server.
Your CVS-password will be stored (encrypted) in ~/.cvspass, so you don't have to run that command every time, you want to use CVS. If you don't want to have your password stored in that file, run "cvs logout" after you're done using CVS.
Note: For all of the following commands to work, CVS have to know your CVSROOT. Normally CVS will know this already (it's stored in directory/CVS/Root, created by CVS when you checked out a module), but if you're using CVS for the first time or adding a new module, you have to setup your CVSROOT yourself as mention above.
Adding users to a CVS-repository
You can add users to your CVS-repository in two ways, either by using the admin page on the CVS-server or by following this guide:
First run the following command to check out the password file for the CVS-repository:
cvs checkout CVSROOT/passwd
Add one or more users to the password file. In this example we'll add the user s801234 to the password file
htpasswd CVSROOT/passwd s801234
Start your favorite texteditor and make sure that all the lines in CVSROOT/passwd ends with ":cvs", just like the first line with your own encrypted password.
Next you'll have to update the password file on the CVS-server. This is done using the normal CVS commit-command:
cvs commit CVSROOT/passwd
Since you no longer need a local copy of the password file, you can remove it using
cvs release -d CVSROOT
Type "yes" to delete the local files.
The $CVSROOT of s801234 should be:
:pserver:s801234@cvs.gbar.dtu.dk:/home/cvs/LOGIN/REPOSITORY
(where LOGIN most likely is your login)
Adding a read-only account to a CVS-repository
Just like normal read/write accounts, a read-only account can be added in two ways. Either by using the admin page on the CVS-server or by following this guide:
First check out the password file:
cvs checkout CVSROOT/passwd
Add the following line to CVSROOT/passwd using your favorite texteditor:
anonymous::cvs
and add this line to CVSROOT/readers:
anonymous
If you don't want to, you don't have to name the read-only account "anonymous", but it's pretty much a standard name for a read-only account. Just change "anonymous" to something else in both files (and in the $CVSROOT we'll mention later).
Tell CVS that CVSROOT/readers should be uploaded to the CVS-server:
cd CVSROOT ; cvs add readers ; cd ..
Now do a commit to upload the files:
cvs commit CVSROOT/passwd CVSROOT/readers
You can remove the local copies of "passwd" and "readers" using
cvs release -d CVSROOT
Type "yes" to delete the local files.
The $CVSROOT for the read-only account is:
:pserver:anonymous@cvs.gbar.dtu.dk:/home/cvs/LOGIN/REPOSITORY
(where LOGIN most likely is your login)
Basic CVS usage
Creating a new CVS module
To create a new CVS module, you can use the cvs import command, which takes the following parameters:
cvs import [-options] repository vendortag releasetag
The easiest way of understanding, is by looking at an example:
- First go to the directory you want to place on CVS. In this example this is a directory called project1 placed in the users home dir.
cd ~/project1
- Now we import this as a new module:
cvs import -m "New project module" project1 s001234 start
The -m defines the import message "New project module". Unless you give the import command a message here, you will be prompted for it afterwards. After the message a string project1 appears. This is the name of the module that will be placed on CVS: $CVSROOT/project1. You could have placed project1 in a subdir e.g. projects/project1, which would then be where the module would be placed. The student number appearing after is the vendor tag, which is a name for the module owner. Last but not least we give the import command a release tag: start. This indicates that our module is at a starting version.
Checkout a CVS module
To checkout a module called project1 to the current directory type:
cvs checkout project1
If you want to checkout the module to a specific directory ~/projects type:
cvs checkout -d ~/projects project1
Add a file
To add a file called report.tex type:
cvs add report.tex
Be sure that the file is in the checked out module folder, that you want to add it to.
Committing the changes you have made
To commit the changes you have made to a module type:
cvs commit
You have to be standing in the directory of the module you want to commit.
Updating your local version of the module
To update the local version of the module you have checked out, go to the module folder and type:
cvs update
Remove a file from the module
To remove a file called picture.jpg from a module type:
cvs remove picture.jpg
See also
See also this guide: http://ximbiot.com/cvs/manual/cvs-1.11.21/cvs_7.html#SEC69
Using another editor for log-messages
By default CVS will use "vi" as the editor for log-messages. You can change this behavior by setting one of the following environment variables: $CVSEDITOR, $EDITOR or $VISUAL.
If you set more the one of these, $CVSEDITOR takes precedence over $EDITOR, which takes precedence over $VISUAL.
Windows
If you want to use CVS on your Windows computer at home, we recommend you try TortoiseCVS.
For CVS use on the Windows machines on DTU, you may wish to follow this guide, kindly provided and maintained by s042551: WinCVS.
Troubleshooting
- The CVS login command fails:
cvs login: failed to open <path_to_your_home_dir>/.cvspass for reading: No such file or directory cvs [login aborted]: fatal error: exiting
- This can be solved by issuing the following command:
touch $HOME/.cvspass ; chmod go-r $HOME/.cvspass
The old CVS-server on logos.gbar.dtu.dk will be closed July 1st, 2007. Contact us and we will try to find an easy way to move your CVS-repository to the new server. The transfer will not happen automatically, since it involves some work on your part.

