-- Getting Ready to Use CVS
First set the variable CVSROOT to /class/`username`/cvsroot
[Or any other directory you wish]
[For csh/tcsh: setenv CVSROOT ~/cvsroot]
[For bash/ksh: CVSROOT=~/cvsroot;export CVSROOT]
Next run
cvsinit. It will create this directory along with the subdirectory CVSROOT and put several files into CVSROOT.
-- How to put a project under CVS
A simple program consisting of multiple files is in /workspaces/project.
To put this program under cvs first
cd to /workspaces/projectNext
cvs import -m "Sample Program" project sample startCVS should respond with
N project/Makefile
N project/main.c
N project/bar.c
N project/foo.c
No conflicts created by this importIf your were importing your own program, you could now delete the original source.
(Of course, keeping a backup is always a good idea)
-- Basic CVS Usage
Now that you have added 'project' to your CVS repository, you will want to be able to modify the code.
To do this you want to check out the source. You will want to cd to your home directory before you do this.
cdcvs checkout projectCVS should respond with
cvs checkout: Updating project
U project/Makefile
U project/bar.c
U project/foo.c
U project/main.cThis creates the project directory in your home directory and puts the files: Makefile, bar.c, foo.c, and main.c into the directory along with a CVS directory which stores some information about the files.
You can now make changes to any of the files in the source tree.
Lets say you add a
printf("DONE\n"); after the function call to bar()
[Or just cp /class/bfennema/project_other/main2.c to main.c]
Now you have to check in the new copy
cvs commit -m "Added a DONE message." main.cCVS should respond with
Checking in main.c;
/class/'username'/cvsroot/project/main.c,v <-- main.c
new revision: 1.2; previous revision: 1.1
doneNote, the -m option lets you define the checking message on the command line. If you omit it you will be placed into an editor where you can type in the checking message.
-- Using CVS with Multiple Developers
To simulate multiple developers, first create a directory for your second developer.
Call it devel2 (Create it in your home directory).
Next check out another copy of project.
- HINT: cvs checkout project
Next, in the devel2/project directory, add a
printf("YOU\n"); after the
printf("BAR\n");[Or copy /class/bfennema/project_other/bar2.c to bar.c]
Next, check in bar.c as developer two.
- HINT: cvs commit -m "Added a YOU" bar.c
Now, go back to the original developer directory.
[Probably /class/'username'/project]
Now look at bar.c. As you can see, the change made by developer one has no been integrated into your version. For that to happen you must
cvs update bar.cCVS should respond with
U bar.cNow look at bar.c. It should now be the same as developer two's.
Next, edit foo.c as the original developer and add
printf("YOU\n"); after the
printf("FOO\n");[Or copy /class/bfennema/project_other/foo2.c to foo.c]
Then check in foo.c
- HINT: cvs commit -m "Added YOU" foo.c
Next, cd back to developer two's directory.
Add
printf("TOO\n"); after the
printf("FOO\n");[Or copy /class/bfennema/project_other/foo3.c to foo.c]
Now type
cvs status foo.cCVS should respond with
===================================================================
File: foo.c Status: Needs Merge
Working revision: 1.1.1.1 'Some Date'
Repository revision: 1.2 /class/'username'/cvsroot/project/foo.c,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
The various status of a file are:
Up-to-date
The file is identical with the latest revision in the repository.
Locally Modified
You have edited the file, and not yet committed your changes.
Needing Patch
Someone else has committed a newer revision to the repository.
Needs Merge
Someone else has committed a newer revision to the repository, and you have also made modifications to the file.
Therefore, this is telling use we need to merge our changes with the changes made by developer one. To do this
cvs update foo.cCVS should respond with
RCS file: /class/'username'/cvsroot/project/foo.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
Merging differences between 1.1.1.1 and 1.2 into foo.c
rcsmerge: warning: conflicts during merge
cvs update: conflicts found in foo.c
C foo.cSince the changes we made to each version were so close together, we must manually adjust foo.c to look the way we want it to look. Looking at foo.c we see:
void foo()
{
printf("FOO\n");
<<<<<<< foo.c
printf("TOO\n");
=======
printf("YOU\n");
>>>>>>> 1.2
}
We see that the text we added as developer one is between the ======= and the >>>>>>> 1.2.
The text we just added is between the ======= and the <<<<<<< foo.c
To fix this, move the
printf("TOO\n");to after the
printf("YOU\n");line and delete the additional lines the CVS inserted. [Or copy /class/bfennema/project_other/foo4.c to foo.c]
Next, commit foo.c
cvs commit -m "Added TOO" foo.cSince you issued a cvs update command and integrated the changes made by developer one, the integrated changes are committed to the source tree.
-- Additional CVS Commands
To add a new file to a module:
- Get a working copy of the module.
- Create the new file inside your working copy.
- use cvs add filename to tell CVS to version control the file.
- use cvs commit filename to check in the file to the repository.
Removing files from a module:
- Make sure you haven't made any uncommitted modifications to the file.
- Remove the file from the working copy of the module. rm filename.
- use cvs remove filename to tell CVS you want to delete the file.
- use cvs commit filename to actually perform the removal from the repository.
For more information see the cvs man pages or the cvs.ps file in cvs-1.7/doc.
---------------
copy from
http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/cvs/