CVS

  • Access a new repository
    • local repository
      #> cvs -d /usr/local/cvs command
    • password-authenticated server
      #> cvs -d :pserver:jrandom@cvs.foobar.com:/usr/local/cvs command
      the password can be stored in ~/.cvspass with
      #> cvs -d :pserver:jrandom@cvs.foobar.com:/usr/local/cvs login
      and can be removed from ~/.cvspass with
      #> cvs -d :pserver:jrandom@cvs.foobar.com:/usr/local/cvs logout
    • external connection program
      #> CVS_RSH=rsh; export CVS_RSH
      #> cvs -d :ext:jrandom@cvs.foobar.com:/usr/local/cvs command
    • the other protocols are kserver (Kerberos) and gserver (Generic Security Services API)
    • the -d flag can be replaced by defining the environment variable CVSROOT
      #> CVSROOT=:pserver:jrandom@cvs.foobar.com:/usr/local/cvs; export CVSROOT
  • create a project
    #> cvs import -m "log msg" projname vendortag releasetag
  • Checking out a working copy
    • #> cvs checkout myproj
      or
      #> cvs co myproj
    • specifying the revision
      #> cvs checkout -r 1.3 myproj
    • specifying the tag
      #> cvs checkout -r MyTag myproj
    • list all the modukes
      #> cvs co -c
  • Creating/removing elements
    • creating a file requires two steps: first the add command on it, then commit:
      #> cvs add newfile.c
      #> cvs ci -m "added newfile.c" newfile.c
    • keyword expansion and line-ending conversion must be turned off to add binary files:
      #> cvs add -kb newfile.c
    • it is also possible to remove keyword expansion for some files:
      #> cvs add -ko newfile.c
    • removing a file requires first to remove the file from the working directory:
      #> rm newfile.c
      #> cvs remove newfile.c
      #> cvs ci -m "removed newfile.c" newfile.c
    • creating a directory requires just the add command:
      #> mkdir newdir
      #> cvs add newdir
    • to remove a directory from a project, first remove all the files in it
      #> cd newdir
      #> rm file1 file2 file3
      #> cvs remove file1 file2 file3
      #> cvs ci -m "removed all files" file1 file2 file3
      #> cd ..
      #> cvs update -P
      the -P option tells update to prune all empty directories
    • rename a file
      #> mv oldname newname
      #> cvs remove oldname
      #> cvs add newname
      #> cvs ci -m "renamed oldname to newname" oldname newname
    • rename a directory
      #> mkdir newdir
      #> cvs add newdir
      #> mv olddir/* newdir
      mv: newdir/CVS: cannot overwrite directory (this is not a problem)
      #> 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
  • status
    #> cvs status hello.c
  • History
    • dump the log of the file
      #> cvs log hello.c
    • for each file of the file, indicate whan, who and on which revision the change has been done
      #> cvs annotate hello.c
  • Update
    • #> cvs update
    • to a given revision
      #> cvs update -r 1.2
    • to a given tag
      #> cvs update -r MyTag
  • Diff
    • #> cvs diff
    • use
      -c
      to perform a context diff
      #> cvs diff -c foobar.c
    • use
      -r
      to specify the version to use as the reference to be compared with the working copy
      #> cvs diff -r 1.218.2.14 toto.c
      or both versions
      #> cvs diff -r 1.218.2.14 -r 1.218.2.13 toto.c
  • tkdiff
    • compare a file with its repository revision
      #> tkdiff hello.c
    • compare two text files
      #> tkdiff foo bar
  • commit
    #> cvs commit -m "print goodbye too" hello.c
    or
    #> cvs ci -m "print goodbye too" hello.c
  • Tag
    • a tag name starts with a letter and contain letters, digits, hyphens (-), and underscores (_).
    • CVS has two different kinds of tags:
      Sticky tags which are tightly bound to one particular revision number for a given file
      Branch tags that allow you to check in new revisions.
    • cvs tag uses a file system hierarchy determine which revisions to associate with the label
      cvs rtag works directly on the repository.
    • create a sticky tag from an existing hierarchy
      #> cvs tag MyTag
    • create a branch tag from an existing hierarchy
      #> cvs tag -R -b MyTag
    • create a branch tag from an existing tag
      #> cvs tag -r ExistingTag -b MyTag
    • move the tag MyTag to version 1.11 for the foobar.c file
      #> cvs tag -r 1.11 -F MyTag foobar.c
    • delete a tag
      #> cvs rtag -d MyTag MyProject
  • Help
    • return the version of the client and of the server
      #> cvs version
    • return the list of synonyms
      #> cvs --help-synonyms

See also: links
Last update: October 25th, 2010
🧭
✉️
🔎