Say you have an existing directory structure that you want to source control. These steps explain how to do it. The first thing you want to do is put the files in the structure that you would like to keep them in (files can be moved around later if necessary). Here's an example file structure:
c:\WorkSpace\projectA
readme.txt
bin\script1.pl
bin\script2.pl
bin\shell1.sh
bin\shell2.sh
docs\index.html
docs\help1.html
docs\help2.html
c:\WorkSpace\projectB
info.txt
docs\index.html
docs\chapter1\help1.html
docs\chapter1\help2.html
docs\chapter2\help1.html
docs\chapter2\help2.html
docs\chapter3\help1.html
files\script1.pl
files\script2.pl
files\shell1.sh
files\shell2.sh
c:\WorkSpace\projectC
foo.pl
test.pl
This example has files organized into three different projects. Each can exist in CVS separately and still be related.
>mkdir c:\cvsroot\CVSROOT
CVSROOT=c:\cvsroot\CVSROOT; export CVSROOT
The following steps are based on the example shown above. This will add the files into the CVS repository under a new directory called projects. "projects" will be a new directory that you have all of your projects under. It will replace the "WorkSpace" directory that was used before.
cd c:\WorkSpace\projectA
cvs import -m "importing initial version of files" projects/projectA mycompany start
cd c:\WorkSpace\projectB
cvs import -m "importing initial version of files" projects/projectA mycompany start
cd c:\WorkSpace\projectC
cvs import -m "importing initial version of files" projects/projectA mycompany start
The files are directories are now all added into the repository.
Before deleting your files, make sure the repository was created successfully. To do this, make a temporary directory somewhere and check out your source files.
cvs co projects
The output of this command will look something like this:
U projects/projectA/readme.txt U projects/projectA/bin/script1.pl U projects/projectA/bin/script2.pl ...
The "U" standards for update and indicates that the file was updated (i.e. created) on your machine. Alternatively, you could checkout each individual project as follows:
cvs co projects/projectAcvs co projects/projectBcvs co projects/projectC
Go to the directory you want to add the directory in and create the directory
the way you would normally do it: cd newDirectoryName. Next
you need to tell CVS that it has been added. To do this use the cvs add
command as follows:
cvs add newDirectoryName.
To add a binary file to cvs, you must add the file with the -kb option and then commit the file.
To modify a file and save it in your CVS repository, just edit as you would normally. When you want to commit your changes to the repository, use the cvs commit command again.
cvs commit -m "explanation of what changed" filename
That's it! You now have a record of what was changed and reverse back to older versions of the file if you need to.
To know what version of file you have, use the cvs status command:
cvs status filename
You'll see a bunch of information about the file in CVS with this command, but the "Working revision" will tell which version of the file you have.
You can use the cvs log command to see what other versions of a file are availabile and see the message that was given when the file was commited into cvs.
cvs log filename
To determine the differences between to two versions of the same file you can use the cvs diff command:
cvs diff -r 1.5 -r 1.4 filename
This command compares version 1.5 and version 1.4 of the file and shows you the differences.
To get an old version of a file, use the cvs update command:
cvs update -r 1.4 filename
This command gives you version 1.4 of the specified file.