Download the latest version of CVS from http://ftp.gnu.org/non-gnu/cvs/binary/stable/x86-woe/ and copy the 'cvs.exe' to C:\Program Files\CVS\cvs.exe 1. Set environment variables needed by CVS under USER variables. * Path - C:\Program Files\CVS * CVSROOT - C:\Web\ * CVSEDITOR - "C:\Program Files\Windows NT\Accessories\wordpad.exe" or "%SystemRoot%\system32\notepad.exe" * Reboot your system 2. Create directory C:\Web and then create 'CVSROOT' within C:\Web * C:\Web * C:\Web\CVSROOT * Note: CVS will automatically look in C:\Web\CVSROOT based on the environment variable that was set above. * Note: The directories used in this guide are just examples (C:\Web, C:\Temp, etc) 3. Open a command prompt and confirm you're in C:\Web and then run the following command. This will populate C:\Web\CVSROOT which will hold all the information that makes CVS work. * cd C:\Web * cvs init 4. Now you are able to start working on the files you wish to add to CVS. You can create some new files in the working directory of your choice (e.g. C:\Temp). In this case, I create a folder called 'project_01' and with Notepad I create a file 'index.html' within that folder. I add some HTML to index.html and save the file. * C:\Temp\project_01 * C:\Temp\project_01\index.html 5. We are going to import this directory into CVS as our first project. * Open a new command prompt * cd C:\Temp\project_01 * cvs import -m "My first project" project_01 jdoe start * Note: cvs import -m "comment for project" [directory name] [vendor] [release tag] * Note: When starting a new project you can use your 'username' for the vendor and 'start' for the release. This just makes it easy for instruction purposes. cvs import: cwd=C:\Temp\project_01 ,current=C:\Temp\project_01 N project_01/index.html No conflicts created by this import 6. We have our first project created and it contains one file. We have trustingly imported it into CVS for safe keeping. The next logical step would be to check out the files and continue working on our project. Since our files now reside in CVS, we can safely clear our working directory and check out our project. You see, CVS doesn't care about our local files anymore. It only cares about what resides within CVS. So, before we can make any more changes to our project we need to get the files from CVS. 7. Lets clear our working directory and get (e.g. check out) our project. * Using Windows, delete "project_01" from our working directory. * Open a new command prompt * cd C:\Temp * cvs get project_01 * Note: It will get the files and place them in the current directory you're in. cvs checkout: cwd=C:\Temp ,current=C:\Temp 8. Now you can edit the file index.html in your favorite editor (e.g. Notepad) and save it. 9. We want to commit the changes we made. * With our command prompt still open * cd C:\Temp\project_01 * cvs commit -m "made some changes" index.html Checking in index.html; C:\Web/project_01/index.html,v <-- index.html new revision: 1.2; previous revision: 1.1 done 10. Now we may want to add a new file to our project. * Using Windows, go into our working directory C:\Temp\project_01 * Create a new file 'new.html' using your favorite editor (e.g. Notepad). Add some HTML and save the file. * cvs add new.html cvs add: scheduling file `new.html' for addition cvs add: use 'cvs commit' to add this file permanently * cvs commit -m "added new page" cvs commit: Examining . RCS file: C:\Web/project_01/new.html,v done Checking in new.html; C:\Web/project_01/new.html,v <-- new.html initial revision: 1.1 done 11. Later on we may decide to remove this file we just added. * using Windows, go into our working directory C:\Temp\project_01 * First delete the actual file from within Windows and then we tell CVS it's gone. * cvs remove new.html cvs remove: scheduling `new.html' for removal cvs remove: use 'cvs commit' to remove this file permanently * cvs commit -m "delete new.html" cvs commit: Examining . Removing new.html; C:\Web/project_01/new.html,v <-- new.html new revision: delete; previous revision: 1.1 done 12. Now we just realized we made a huge mistake and need to restore the file we just removed. To do this, we are going to restore the file from a previous version. 13. First we are going to check the history and determine when we added the file. Since we just created the file and then added it, we don't care about revisions at the moment. We want to know when the file was first added. * Open a command prompt and cd into the CVS repository and into our project * cd C:\Web\project_01 * cvs history -x A A 2008-02-12 02:29 +0000 jdoe 1.1 new.html project_01 == C:\Temp\project_01 14. Now that we know when we added the file, we can restore our project as if nothing ever happend. It's kind of like Back to the Future but not as cool since we don't get to drive the delorean. But better in other ways since we don't get shot at by Libyan terrorists. * Create a fresh working directory or clear out your existing working directory (e.g. C:\Temp). * Open a new command prompt * cd C:\Temp * We want to restore the project based on a time after we checked the files in. In this case we added the files at 02:29, so 02:30 should be fine. * cvs checkout -D "2008-02-12 02:30 +0000" project_01 cvs checkout: cwd=C:\Temp ,current=C:\Temp cvs checkout: Updating project_01 U project_01/index.html U project_01/new.html 15. This step is very important. Since 'new.html' now appears in our local directory, now We need to copy it to a safe place outside of our current working directory. 16. Now that we have our file back and copied to a safe place, we want to get it checked back into our project. However, before we can do this we need to untag the file which will allow us to check it back in. You see, CVS is pretty smart. It's protecting us from checking in an old file and accidently overwriting a newer file. We need to unflag it first and then check it back in. * cd C:\Temp\project_01 * cvs update -A cvs update: Updating . cvs update: new.html is no longer in the repository * Note: CVS can act like a know-it-all and is telling us that new.html is no longer in our project. We know that buddy! We're the ones that deleted it! * Note: The scary part is that it just removed new.html from the project folder we just restored when we ran the update command. That's why we had to copy it to a safe place. * Note: It's still in the CVS repository as a revision. We could restore the file again if we wanted to. 17. To add even more to the scariness, we're going to copy new.html back into our projector folder and run the update command again. * cvs update -A cvs update: Updating . cvs update: use `cvs add' to create an entry for new.html ? new.html 18. Finally, we're going to do as we're told and get our file added back in. * cvs add new.html cvs add: re-adding file new.html (in place of dead revision 1.2) cvs add: use 'cvs commit' to add this file permanently * cvs commit -m "restoring the file finally!" cvs commit: Examining . Checking in new.html; C:\Web/project_01/new.html,v <-- new.html new revision: 1.3; previous revision: 1.2 done That's all folks. Hopefully this should be enough to get you started with CVS. Please let me know if you have any changes, corrections, or suggestions.