Getting Started With CVS
If you are developing software then version control is a must. Actually, it helps automate a lot of tasks you would otherwise have to do yourself. Here are some tips on using CVS and a couple ideas on how I do things.
Getting Started
Create a directory somewhere; preferably somewhere that gets backed up. Set the $CVSROOT environment variable to the path of you just created. It's best to just put this in your .profile, but you can simply run the following for temporary purposes:
export CVSROOT=/path/cvs;
A module is a collection of files as I see it. You can call it a project, a library, or whatever. I will refer to everything as a module as CVS does.
Initialize the repository (this only needs to be done one time and you should never have to do it again):
cvs init
Go into the directory of a project and import it:
cvs import [project] [initials] [tag]Checkout a module:
cvs co [project]Update your current working directory with a CVS version (you only need to do this if updates have been made in CVS that are newer than your current working version):
cvs update [project]Add a file to a module (you'll need to run a commit after this):
cvs add fileRemove a file from a module (if you want cvs to delete the file in the current directory and remove it from the module use the -f option):
cvs remove file cvs remove -f file
Notice that the -f option comes after remove as it is a parameter to the remove command and not to the cvs command.
Those are the basic commands you'll be using. It is important to note the CVS does not version directories. So, if you delete a directory and then do a commit and checkout the empty directory will be there. To help with this, just usecvs co -P projto purge any empty directories.
Sharing Modules Between Projects
I usually have a group of utilities and libraries I share between projects. This is the best way I've figured out how to successfully share modules between projects.
Add your shared module to CVS just like you would add a new project with import.
Then, checkout the CVSROOT/modules file and add some lines to it:cvs co CVSROOT/modulesThis example shows what I usually do for including modules in some of my projects:
utilsa -d src &utils proj proj &utilsa
This creates an alias for the utils library and then adds it to the project proj. Notice that I included the utils module in the proj src directory. If updates are made to the utils library, they will be committed when you commit the proj module.
Then, check the modules file back in. I'm warning you. You must checkout and checkin the modules file. Don't manually edit it straight in CVSROOT because when you check it in it needs to rebuild some other core CVS files.
Starting Branches
Create a release branch:cvs co proj cd proj cvs tag -b TAGCheckout a branch:
cvs co -P -r TAG proj
Checking Current Working Version With Old Repository Version
Find out what versions there are in cvs:cvs log filename
Compare the version we want with the current working version:cvs diff -r version filename
Another great resources is http://dev.panopticsearch.com/cvs-notes.html