CVS Examples
First, of all, check out: http://cvs.psas.pdx.edu/cvsbook ! It's a great reference.
General Commands
Here is a list of five of the most commonly used CVS commands, followed by a description of their typical sequence of use:
cvs co <module_name> |
check out a CVS module (project) |
cvs ci |
check in changes (same as 'commit') |
cvs update |
get other members' changes on a project already checked out. PLEASE always check the diff (see the next command) to make sure that any modified files you're about to commit are what you think you're committing. |
cvs diff <filename> |
show the difference between the local file and the one in CVS |
cvs add <filename or dirname> |
add a file or directory to a project |
cvs remove <filename or dirname> |
remove a file or directory from a project * |
One more command, generally used by developers and only at the beginning of version controlled project, is the import
command for cvs. This command imports a new module in the archive, and has several required arguments:
cvs import <module_name> |
check out a CVS module (project) |
"cvs update" Responses
You should be running cvs update
all the time to get the latest bits. The reponse codes are:
? |
CVS has no idea what this file is (new files are completely ignored until you cvs add them). |
U |
A file that was in CVS but not your local directory was written to the local directory. |
P |
CVS has patched the file in your local directory to match the new changes in the CVS repository |
M |
CVS has happily merged the file in your local directory with changes posted by someone else since your last checkout. M is good because it means that CVS has merged the files without conflict, so you don't have to do anything but cvs commit to post your changes. |
C |
CVS is whining that since you last checked out the file, someone else made changes and you made changes in the same place so it doesn't know what to do. You'll need to merge the files yourself. |
To get a preview of what cvs update
would do without actually changing any files, use the -n
flag to cvs
like this:
cvs -n update
To make cvs quieter about processing each directory, use the -q
flag; to make it explain more about what it is doing, use the -v
flag.
Specific Examples
cvs admin -o <revision #> <filename> |
Remove a checked in revision ("uncommitting", if you will) |
cvs admin -m <revision>:"message" <filename> |
Change a commit message: see http://cvs.psas.pdx.edu/cvsbook/cvsbook_5.html#SEC80 |
Other Useful Things To Know
If your diff looks like it's the whole bloody file and you're running a Windows machine, you probably have a CR/LF line ending problem... OR your text editor is changing existing tabs to spaces or something like that. In cygwin or Linux, you can file <filename>
to get the filetype, including the kind of line ending. Then you can run dos2unix <filename>
to change them.