1. IMPORTANT - 11/13/2015: In light of a possible breach we have scrubbed all passwords. You will need to request a password reset through the site. Click here for more information.

Tips: CVS

Discussion in 'Linux Tips' started by LinuxDotOrg, Jul 9, 2013.

  1. LinuxDotOrg

    LinuxDotOrg Administrator

    Jul 9, 2013
    Likes Received:
    CVS stands for 'control versions system'. If you are a software developer, web developer or if you use a computer to maintain any kind of project (it could even be a novel you're writing, for example), you can use CVS to keep track of changes to your project. CVS is also a way to let people collaborate with you.

    Get a whole project

    If you're asked to collaborate on a project and you need to download everything, you would first place this in your .bashrc file:

    export CVSROOT=:ext:www.server.com:/path/to/repository
    export CVS_RSH=ssh
    You would, of course, change the server location and the path to those files on the server to the real ones.

    The CVS

    Then you would issue this command:

    cvs -q get the_project

    Frequently Used CVS Commands

    These are the commands that you will use most often:
    This command adds a file to the repository:

    cvs add file.php
    Extra tip: If you are adding an image or binary file, you should use cvs add -kb file.jpg for example. This will indicate to CVS that the file is not a plain text file. Since CVS was designed to handle software project management, CVS is meant to deal with plain text files primarily.

    The following command updates a file in the repository after you've made changes to your own copy

    cvs update -A file.php
    The -A tag reminds you to 'commit' the file, which is our next command.

    This command 'commits' the file or sends it to the repository

    cvs commit -m "added new variables" file.php
    The -m switch is to add a message to the file. This is usually a short description of the changes you've made.

    The following will remove a file from the repository

    cvs remove file.php
    The removal needs to be 'committed' as well (cvs commit ... etc.)

    The following will show you the 'log' for a file, which shows the changes you've made since the file was created.

    cvs remove file.php

    A 'diff' shows the difference in versions of files in a cvs repository.
    To get diff between versions 1.1 and 1.2

    cvs diff -r 1.1 -r 1.2 file.php

    If you've changed a file locally and you want to see a differences between your copy and the repository's copy:

    cvs -Q diff -c file.php
    If you've got enscript installed, you can get what I call a 'pretty' diff

    cvs -Q diff -c file.php | enscript -Ediff -o file.php.diff.ps
    This will output a nice printable file in Postscript format with the differences marked in bold.

    get locally modified
    When you're working on a project, sometimes you forget to check in your changes. If you want to find out which files need checking in, just issue this command:

    cvs -f status *.php | grep 'Status: Locally Modified'
    Revert to previous version

    If you've made changes to a file and you don't like the result. You can start over again by converting back to a previous version. Just issue this command: (the example assumes you're on vers. 1.4 or more)

    cvs update -r 1.3 file.php
    Status of directory

    This will go through all of the files in the project, give you the status of the files and output it to a file called 'status_project_YYYY-MM-DD'.

    cvs -f status -v my_project/ > status_project_`date +%Y-%m-%e`
    Update directory

    The following command will update the files in a specific directory of your project

    cvs -q update -d my_project/sql
    Change default CVS editor

    vi is the default editor for cvs. You can change this to emacs, if you'd like, by adding this to your .bashrc.

    [CODE]export CVSEDITOR=/usr/bin/emacsclient
    Emacs has some features for CVS support that may come in handy.

Share This Page