|
CVS in 60 Seconds
|
A CVS Tutorial
|
Links |
Creating the cvs repository |
|
The first step is to create the cvs repository (also known as a tree).
|
Adding your project to the repository |
|
If the files you want to install in CVS reside in `wdir', and you want them to appear in the repository as `$CVSROOT/myproject', you can do this: $ cd wdir Unless you supply a log message with the `-m' flag, CVS starts an editor and prompts for a message. The string `MyBrand' is a vendor tag, and `start' is a release tag. They may fill no purpose in this context, but since CVS requires them they must be present. You can now verify that it worked, and remove your original source directory. $ cd .. Erasing the original sources is a good idea, to make sure that you do not accidentally edit them in wdir, bypassing CVS. Of course, it would be wise to make sure that you have a backup of the sources before you remove them.
|
Checking out the project |
|
You can get "myproject" files from your CVS repository by following commands: $cvs co myproject A subdirectory named as "myproject" will be created under current directory. If you want the files to be placed into the current directory and you don't want cvs to create a subdirectory, try this instead: cvs co -d . myproject Remote project checkout example: supposing you want to access the module `foo' in the repository `/usr/local/cvsroot/', on machine `faun.example.org', you are ready to go: (make sure to use absolute path, eg. /usr/...) cvs -d :ext:myusername@faun.example.org:/usr/local/cvsroot checkout foo
|
Checking out a single file |
|
If youi want to get a single file "testFile" from the repository, you do it like this: $cvs co myproject/testFile If you want a particular revision of that file: $cvs co -r1.1 myproject/testFile That will give you revision 1.1 of that file. Perhaps the file lives in a subdirectory of the project. No problem. Just supply the pathname $cvs co myproject/path/to/thefile/testFile
|
Checking things back in |
|
Once you are happy with any changes you have made, you can commit these changes to the repository by doing this: $ cvs commit -m "Added an optimization heap in FisrtPass.java" `-m' flag used to avoid starting an editor. You can specify the log message on the command line as above. I much prefer this way. You'd better know how to use "vi" if you commit without "-m" flag. :-) check back a single file by doing this: $ cvs commit -m "Added an optimization heap in FisrtPass.java" FirstPass.java
|
Adding new files to the repository |
|
If a new file is needed, you can add it to the repository by doing this: $ cvs add mynewscript.pl On your next commit, the file will be added to the repository.
|
Removing files from the repository |
|
If a file is not needed, you can remove it from the repository by doing this: $ cvs remove mynewscript.pl On your next commit, the file will be removed from the repository.
Here is an example of removing several files: $ cd test $ rm *.c $ cvs remove cvs remove: Removing . cvs remove: scheduling a.c for removal cvs remove: scheduling b.c for removal cvs remove: use 'cvs commit' to remove these files permanently $ cvs ci -m "Removed unneeded files" cvs commit: Examining . cvs commit: Committing .
If you execute remove for a file, and then change your mind before you commit, you can undo the remove with an add command. $ ls CVS ja.h oj.c $ rm oj.c $ cvs remove oj.c cvs remove: scheduling oj.c for removal cvs remove: use 'cvs commit' to remove this file permanently $ cvs add oj.c U oj.c cvs add: oj.c, version 1.1.1.1, resurrected If you realize your mistake before you run the remove command you can use update to resurrect the file: $ rm oj.c $ cvs update oj.c cvs update: warning: oj.c was lost U oj.c
|
Removing directories |
|
In concept removing directories is somewhat similar to removing files--you want the directory to not exist in your current working directories, but you also want to be able to retrieve old releases in which the directory existed. The way that you remove a directory is to remove all the files in it. You don't remove the directory itself; there is no way to do that. Instead you specify the `-P' option to cvs update or cvs checkout, which will cause CVS to remove empty directories from working directories. (Note that cvs export always removes empty directories.) Probably the best way to do this is to always specify `-P'; if you want an empty directory then put a dummy file (for example `.keepme') in it to prevent `-P' from removing it. Note that `-P' is implied by the `-r' or `-D' options of checkout. This way CVS will be able to correctly create the directory or not depending on whether the particular version you are checking out contains any files in that directory.
|
Rename files or directory |
|
cvs commit: Up-to-date check failed for `about.html' |
|
Sometimes, when you try to commit stuff back to the database, things don't go as planned. For example: $ cvs commit It was suggested to me that about.html was older than that which was in the repository and that I should try this instead: $ cvs update about.html
|
other useful options |
|
Web Resources |
|
http://ccvs.cvshome.org/servlets/ProjectHome Linux CVS HOW-To & CVS vs. RCS
|
CVS for Windows |
|
CVSNT a multi-platform CVS server engine WinCVS A set of GUI front-end for CVS written in C++
|