Tech Journal Back to Tech Journal

CVS Cheatsheet

List all changes between local copy and version in Server (note quotes!)

$ cvs diff -D 'now'

Print any changes since last update

$ cvs diff

Add file/dir
(will only add a newly created and empty dir. You'll have to "add" every new file you create in it)

$ cvs add file/dir

Remove file/dir

$ cvs remove file/dir

Import an entire directory with files and subdirs:
(note: DON'T put the dir in your CVS-checked-out directory. Import it when it's not there!)

$ cd dir_to_import
$ cvs import -m "message" target/path/in/repository repository name start

Just note, this only imports the directory. You still have to check it out to your local dir, by doing

$ cvs update -d

Commit changes to Repository for specific file

$ cvs commit file

Commit changes with command-line comment

$ cvs commit -m "some text" file

Commit ALL changes to Repository

$ cvs commit

Download ALL changes from repository into local

$ cvs update

Will print out list with these prefixs:
M - changes in local code
U - update has been done to local code due to changes in Repository
P - patch has been done to local code due to changes in the Repository
C - conflict (<<<< and >>>> will mark where)
? - unknown (probably never been in repository)

This will not check out new direcotries, for that use:

$ cvs update -d

Display current status of files (version, edited, etc.)

$ cvs status

CVS doesn't handle binary files very well, or if a file has a CVS-keyword (like $Id$) -- it gets expanded. This is not good. To prevent this, add the file using the -kb option:

$ cvs add -kb problematic_file
$ cvs commit -m "some description" problematic_file

Don't use this for files you want to have good version control on. Since CVS can't really diff binary files well.

One note about stickeness - There are various "sticky" tags that happen after an action. For instance, if you used the command cvs update -rrev filename to revert to an earlier revision of a file, then all the updates, diffs, and operations will be done to that revision. But eventually, someone else might edit the file, and then you have to deal with merging it back into the repository, as a new revision, and just update the currently selected revision.

To get rid of a sticky tag, and tell the CVS system to go back to using the most recent version from now on, do:

$ cvs update -A filename

That will try and merge the local version with the version from the repository, and will clear the sticky tag.

Alternatively, you can do this:

$ mv file file.mine
$ cvs update -A file
$ mv file.mine file
$ cvs commit -m "using my version now" file.mine

This will lose any changes anyone else did in the repository, and put your own version instead.

To deal with binary files automatically, edit $HOME/.cvswrappers If you want all *.swf files to be imported as binary, then you put the following line in .cvswrappers:

*.swf -k 'b'

That will set a sticky of -kb to all imported swf files.

Last updated on 2006-09-16 14:00:00 -0700, by Shalom Craimer

Back to Tech Journal