Filed under: Technical References
Posted: March 7, 2009
CVS is Concurrent Version Control. It can be used to control the versioning of source and document files.
It may be used to house all documents generated in one’s academic work. The benefits to this are that one has all versions of all programs/documents produced and may easily roll back to a previous version. One will also have an easy way of keeping work in sync across multiple machines.
Getting Started
First you need to create your cvs repository directory. E.g.
mkdir ~/cvs
Now we need to add two lines to our .bashrc file located in our home directory. The first line tells CVS to conduct its transactions over the SSH protocol. The second line tells CVS where the repository is located.
echo “export CVS_RSH=/usr/bin/ssh” >> ~/.bashrc echo “export CVSROOT=yourusername@london.cs.uri.edu:/home/ugrad/yourusername/cvs” >> ~/.bashrc
Now just to make sure that your additions to .bashrc went through correctly:
cat ~/.bashrc
If you don’t see the two lines there then go ahead and edit the file in your favorite editor (vim, emacs). Before you continue you should logoff the server and then reconnect. The .bashrc file only runs at logon. If you do not disconnect and reconnect CVS won’t know where the repository is located.
Initial Repository Creation
In your home directory make a directory called school.
mkdir school
Then inside the school directory make a subdirectory designating the current semester.
cd school mkdir spring2005
Now change into that directory and create the initial repository.
cd spring2005 cvs import -m “Initial importation of spring 2005 coursework” spring2005 brandon start
What you have done is created a spring2005 repository with vendortag brandon and starttag start.
Adding Courses to the Semester Repository
Now lets checkout our new spring2005 repository. From the school directory run:
cvs checkout spring2005
Change into that directory and create some course directories.
cd spring2005 mkdir csc212 csc350 csc412 csc402
Now add each directory to the repository.
cvs add csc212 csc350 csc412 csc402
Now commit to push the changes back to the repository.
cvs commit
Our First Programming Assignment
CSC212 has asked you to write a rather difficult Hello World program for lab 1. You’ve written some initial code for your program but want to add it to the repository before implementing an untested algorithm. First upload or move the directory containing your code to your school/csc212/ directory. Assume the lab directory was called lab1 with Hello.java being the program you are working on. To add this data to the repository, do the following:
cd ~/school/spring2005/csc212/ cvs add lab1 cvs add lab1/Hello.java cvs commit
Now you’ll notice that CVS will open an editor window and ask you to write some comments about this version. Write something about it like My initial commit. Program doesn’t work as required. These messages will help you to later sort out the changes you made during different commits. CVS will give you some messages and then your program will be added to the repository. Upload successive versions to the same location and simply issue a
cvs commit
to save those revisions to the repository.
Conclusion
You’re now using version control to maintain your academic work. As an aside you can also commit binary files to CVS but you’ll lose some of CVS capabilities like the ability to show the differences between two versions of the same file. Check the cvs manpage and homepage for additional information. Good luck.
