I recently started using cvs for my web design work – because its the most popular and though subversion is improved, I’ll gain to learn CVS.
References:
http://cvsbook.red-bean.com/ – online CVS manual – excellent
http://developer.gnome.org/tools/cvs.html – more notes
http://durak.org/cvswebsites/howto-cvs/node38.html – cvswrappers file
http://www-bcl.cs.unm.edu/computers/cvs.html – notes
#####Starting things up
add this to .bashrc
export CVSROOT=/home/cvsuser/cvsroot
add this to .cshrc
setenv CVSROOT /home/cvsuser/cvsroot
Initialize cvs – in the directory specified by $CVSROOT
# cvs init
Import projects
# cvs import -m "vtiger codebase import" websitecom_CRM Inspiriat start
Checkout a project for editing
# cvs checkout websitecom_CRM
#####Connect to a remote CVS repository
set CVSROOT and remote shell
# export CVSROOT=":ext:user@some.remote.host.tld:/home/user/cvsrepo"
# export CVS_RSH="ssh"
#####Status commands
Log for a file – see who and related code
# cvs log foo.php
Get status of every file – quite long….
# cvs status
Show status of foo.php
# cvs status foo.php
#####Add/remove/rename files and directories
Add a file
# cvs add newfoo.php
# cvs ci -m "added newfoo.php to project" newfoo.php
Add a binary file
# cvs add -kb binary.exe
# cvs ci -m "added a binary.exe file" binary.exe
Add a directory
# cvs add subdir
Remove file
# rm file.php
# cvs remove file.php
Remove a directory
# cd dir
# rm file1 file2 file3
# cvs ci -m "removed file1 file2 file3"
# cd ..
# cvs update -P (prune empty directories from the working copy, not the repository)
Move a file
# mv oldname newname
# cvs remove oldname
# cvs add newname
# cvs ci -m "renamed oldname to newname" oldname newname
#####Before commit
Look at differences between checked-out and repository copy
# cvs -Q diff -c foo.php
Create a patch of these differences
# cvs -Q diff -c -u -p > newpatchfile.diff
Replace the local copy with one from the repository
# rm file.php ; cvs update file.php
#####Commit / Updates
Commit a specific file
# cvs commit -m "Added sorting by other columns" foo.php
Update your code with others contributions
# cvs update foo.php
#####After Commit
Show difference in revisions 1.1 and 1.2
# cvs diff -c -r 1.1 -r 1.2 foo.php
This command will now show little or nothing – working and repo has same copy
# cvs diff -u -p foo.php
#####Creating patches
Create a patch
# cvs diff -u -p -r 1.1 -r 1.2 foo.php > foo.php.patch
Create patch for using files not in CVS – (the -u -p outputs diff in patch format)
format: `diff -u -p oldfile newfile > patchfile`
# diff -u -p development/foo/fighter.php production/foo/fighter.php > fighter.php.patch
Apply patch to a file
# patch < patchfile
#####Binary files
CVS works fine with binary files and preserving permissions.
Format for binary files and permissions::
* Binary file: `*.jpg -k 'b'` (for a jpg file)
* Preserve permissions: `*.php -ko` (for a php file)
This is part of my cvswrappers file (in CVSROOT).
*.CLASS -k 'b'
*.DOC -k 'b'
*.AVI -k 'b'
*.EAR -k 'b
*.GIF -k 'b'
*.PNG -k 'b'
*.JPG -k 'b'
*.PDF -k 'b'
*.TAR -k 'b'
*.WAR -k 'b'
*.ZIP -k 'b'
*.avi -k 'b'
*.bin -k 'b'
*.bz -k 'b'
*.db -k 'b'
*.bz2 -k 'b'
*.class -k 'b'
*.doc -k 'b'
*.ear -k 'b'
*.exe -k 'b'
*.gif -k 'b'
*.gz -k 'b'
*.hqx -k 'b'
*.ico -k 'b'
*.jar -k 'b'
*.jpeg -k 'b'
*.jpg -k 'b'
*.msi -k 'b'
*.mov -k 'b'
*.mp3 -k 'b'
*.mpg -k 'b'
*.pdf -k 'b'
*.png -k 'b'
*.ppt -k 'b'
*.rpm -k 'b'
*.sit -k 'b'
*.srpm -k 'b'
*.swf -k 'b'
*.tar -k 'b'
*.tbz -k 'b'
*.tgz -k 'b'
*.tif -k 'b'
*.tiff -k 'b'
*.war -k 'b'
*.xbm -k 'b'
*.xls -k 'b'
*.zip -k 'b'
*.sh -ko
*.php -ko
*.ini -ko
*.txt -ko
*.log -ko
*.properties -ko
*.html -ko
*.htaccess -ko
*.js -ko
Anything to add - please leave a comment. This is a work in progress.