LevSelector.com GS, NY
home > CVS Email

CVS
On this page: Other pages:
* main commands
* examples
* working with branches
* our branches
* www.cvshome.org
* cvs_manual
* cvs_quick_ref


 
cvs main commands home - top of the page - email

Here are some useful cvs commands:

cvs -n update
cvs update -d -P
cvs diff -rHEAD somefile
 

getting help:
man cvs
cvs help  - shows main commands and their short description
cvs --help somecommand - to show help for a command, for example:
cvs --help update
cvs --help co
cvs --help-synonyms - shows lsit of shortcuts for commands

CVS commands are:
        add          Add a new file/directory to the repository
        admin        Administration front end for rcs
        annotate     Show last revision where each line was modified
        checkout     Checkout sources for editing
        commit       Check files into the repository
        diff         Show differences between revisions
        edit         Get ready to edit a watched file
        editors      See who is editing a watched file
        export       Export sources from CVS, similar to checkout
        history      Show repository access history
        import       Import sources into CVS, using vendor branches
        init         Create a CVS repository if it doesn't exist
        log          Print out history information for files
        login        Prompt for password for authenticating server.
        logout       Removes entry in .cvspass for remote repository.
        rdiff        Create 'patch' format diffs between releases
        release      Indicate that a Module is no longer in use
        remove       Remove an entry from the repository
        rtag         Add a symbolic tag to a module
        status       Display status information on checked out files
        tag          Add a symbolic tag to checked out version of files
        unedit       Undo an edit command
        update       Bring work tree in sync with repository
        watch        Set watches
        watchers     See who is watching a file


 
Examples home - top of the page - email

get all the tree:
CVSEDITOR=vi; export CVSEDITOR
CVSROOT=/home/slsdev/cvs_repository; export CVSROOT
cvs get Portfolio

update files in your directory  ( -A - fresh update):
cvs update -A
use -n cvs option to see what should happen without actually doing it:
cvs -n update -A

add directories to cvs:
cvs add maint
cvs add amsi

add files to cvs:
cvs add *.txt
cvs add *.pl *.sh

changes >> to cvs:
cvs commit -m "Updated root directory to /home/mydir"   myfile
   use wildcards (but not just '*'),
   use '-n' option to see what should happen without doing it
cvs -n commit -m "Change logic for kerberos_id pattern test" UDB*.sp

misc:
cvs diff -r1.7 somefile    - shows the difference between what is in the directory and in v.1.7 in cvs
cvs diff somefile    -  shows the difference between what is in the directory and what was in the cvs when you got the file from cvs
cvs diff -rHEAD somefile    - show difference between the top version and current directory

Examples:
cvs diff populateUsers.pl
...
diff -r1.6 populateUsers.pl
2c2
<
---
>  # in directory

cvs log | grep populateUsers.pl

vi .cvsignore
cvs add .cvsignore

--------------------------------------------------
When making update, you can use the following 2 options:
    cvs update -d -P
        -P      Prune empty directories.
        -d      Build directories, like checkout does - makes sure that your update will include new directories which somebody else added, but you don't have yet.
--------------------------------------------------
 


 
working with branches home - top of the page - email

Example:
Let DBI be the main development trunk where-to all changes should merge.
We will be merging into the DBI trunk, thus incorporating changes from olddir into the DBI trunk.
 
(jrandom,floss) - trunk  (DBI) (qsmith,paste) - brunch (olddir)
create a regular non-branch tag:
cvs tag Root-of-Somename
cvs update -r Somename-branch
  .. make some editing
cvs commit -m "some comment"
(new version 1.14.2.1)
  .. some editing
cvs commit -m "some changes"
(new version 1.15)
cvs update -j Somename-branch
cvs update
...
C somefile1.txt
...

C meant a conflict - need to resolve.
emacs somefile1.txt
cvs commit -m "merged from Somename-branch (conflicts resolved)"
Let's tag as successfully merged.
cvs tag merged-Somename

emacs ... (do some editing on different files)
cvs ci -m "some comment"
cvs tag Somename-1
emacs ... (do some editing)
cvs commit -m "some comment"
cvs tag Somename-2
cvs -q update -j Somename-branch   -  this is wrong way to do this
 ... confilcts, becase it tries again to get all from the root of the branch.
rm conflicting files
cvs -q update
cvs -q update -j Somename-branch-1 -j Somename-branch
cvs -q commit -m "merged again from Somename (1)"
cvs -q tag merged-Somename-branch-1

Note, that each merge consists of 3 actions:
  - commit everything on the branch and make a tag on the branch side (olddir)
  - go to trunk area (DBI) and do merge between last branch tag - and the last merged
  - create a tag on the trunk (merged- ...)

Question - how to see the tags?


 
our branches home - top of the page - email

Putting the file into the main trunk and into a branch:
Let's say we have the same version of file (v.1.7) in the main trunk (Sybase) and in the DBI branch.
We edit the file in Sybase area and submit it (making version 1.8):
cvs status -v myscript.cgi
cvs commit myscript.cgi

Now we want to merge it into a DBI branch.
We go to the directory where we work with DBI branch and do the following:
cvs status -v   myscript.cgi
cvs update -j 1.7 -j 1.8   myscript.cgi
cvs diff   myscript.cgi
vi   myscript.cgi
pwd
diff   myscript.cgi   ~olddir/myscript.cgi
cvs commit   myscript.cgi
cvs log   myscript.cgi
history


 
some_examples home - top of the page - email

misc.commands:

cvs -Q update
  -q  - be somewhat quiet
  -Q - be absolutely quiet (suppress all diagnostic output except for fatal error messages)
--------------------------------------------------
accessing cvs repository in a particular directory:
cvs -d /usr/local/cvs  command
(to avoid indicating directory every time you can set a CVSROOT env.variable"
CVSROOT=/usr/local/cvs; export CVSROOT
--------------------------------------------------
pserver  - password-authenticated access method

cvs -d :pserver:mylogin@cvs.foobar.com:/usr/local/cvs login
  passwd:

stores passwd in ".cvspass"

cvs -d :pserver:mylogin@cvs.foobar.com:/usr/local/cvs command

To avoid printing all the time:
CVSROOT=pserver:mylogin@cvs.foobar.com:/usr/local/cvs; export CVSROOT
--------------------------------------------------
Other access methods:  ext, kserver, gserver
----------------------------------------------------------
Putting a new project into CVS = import:
cd myproj
cvs import -m "log msg" projname vendortag releastag
for example:
cvs import -m "initial import into cvs" myproj mylogin start

checking out a working copy:
cvs checkout myproj
----------------------------------------------------------
each directory in the project has a CVS subdirectory
cvs update
M hello.c      - this means that hello.c was edited, but not committed yet
cvs diff
...
> some_added_line
...
cvs -Q diff -c         -c option shows fiew lines before and after the change
----------------------------------------------------------
 if no file or directory is given to cvs, it will try to apply command to all files and directories (including going into subdirectories)
----------------------------------------------------------
cvs commit -m "some log message" hello.c
cvs status hello.c
cvs log
to see the difference between revisions:
cvs diff -c -r 1.3 -r 1.4 hello.c
----------------------------------------------------------
How to get back to previos version.
Current version is 1.4. I want to get version 1.3 and commit it as version1.5
cvs -Q update -p -r 1.3 hello.c > hello.c
cvs commit -m "reverted to 1.3 code" hello.c

Another method to do the same:
cvs update -j 1.4 -j 1.3 hello.c
cvs update
cvs commit -m "reverted to 1.3 code" hello.c
----------------------------------------------------------
adding files and directories:
cvs add newfile.c
cvs commit -m "added newfile.c" newfile.c

cvs add mydir
----------------------------------------------------------
removing files and directories:
rm newfile.c
cvs remove newfile.c
cvs commit -m "removed newfile.c" newfile.c

cd mydir
rm file1 file2 file3
cvs remove file1 file2 file3
cvs commit -m "removed all files" file1 file2 file3
cd ..
cvs update -P
  -P option means "Prune" any empty directories
----------------------------------------------------------
Working with Binary files:

use -kb option to turn off both keyword expansion ($Revision$, etc.) and line-ending conversion.

cvs add -kb myfile
cvs commit -m "added binary file" myfile

in some cases you want to disable just the keyword expansion:
cvs add -ko myfile
cvs commit -m "added binary file" myfile
----------------------------------------------------------
Renaming files and directories:
files:
mv oldname newname
cvs remove oldname
cvs add newname
cvs commit -m "renamed oldname to newname" oldname newname

directories:
mkdir newdir
cvs add newdir
mv olddir/* newdir
cd olddir
cvs rm foo.c bar.txt
cd ../newdir
cvs add foo.c bar.txt
cd ..
cvs commit -m "moved foo.c and bar.txt from olddir to newdir"
cvs update -P
----------------------------------------------------------
  .cvsrc file - contains your custom settings for cvs:
diff -c
update -P
cvs -q
----------------------------------------------------------
cvs -q update -D "1999-04-19" - means get the version which existed at the very beginning of this date.
cvs -q update -D "1999-04-19 23:59:59" - means get the version which was at the end of this date (by client time).
cvs -q update -D "1999-04-19 23:59:59 GMT" -  ..... by Greenwich time.
The repository always stores dates in the universal (Greenwich) time.

-D flag sets "sticky date" - this means that updates don't change the working copy. It stays restricted permanently to that date or before (sticky date) unless told otherwise. While in this position - you can not commit new changes of this file.

To remove the sticky date (or any sticky property) run update with "-A" flag:

cvs -q update -A
cvs -Q status hello.c
----------------------------------------------------------
Setting a tag:
cvs -q tag SomeName

retreive a snapshot by tag:
cvs checkout -r SomeName myproj

revert to previous version:
cvs update -r SomeName hello.c
edit file
cvs -q update -A        - without fresh update cvs will not allow to commit
cvs commit -m "some comment" hello.c
 
 

Short commands (synonyms):
 
command synonyms
checkout co, get
commit ci
update up
admin rcs
rdiff patch 'patch' format diffs between releases