L
LinuxDotOrg
Guest
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:
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:
Frequently Used CVS Commands
These are the commands that you will use most often:
This command adds a file to the repository:
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
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
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
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.
Diffs
A 'diff' shows the difference in versions of files in a cvs repository.
To get diff between versions 1.1 and 1.2
If you've changed a file locally and you want to see a differences between your copy and the repository's copy:
If you've got enscript installed, you can get what I call a 'pretty' diff
This will output a nice printable file in Postscript format with the differences marked in bold.
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:
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)
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'.
Update directory
The following command will update the files in a specific directory of your project
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.
Emacs has some features for CVS support that may come in handy.
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:
Code:
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:
Code:
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:
Code:
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
Code:
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
Code:
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
Code:
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.
Code:
cvs remove file.php
Diffs
A 'diff' shows the difference in versions of files in a cvs repository.
To get diff between versions 1.1 and 1.2
Code:
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:
Code:
cvs -Q diff -c file.php
If you've got enscript installed, you can get what I call a 'pretty' diff
Code:
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.
Code:
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:
Code:
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)
Code:
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'.
Code:
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
Code:
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:
[CODE]export CVSEDITOR=/usr/bin/emacsclient
Emacs has some features for CVS support that may come in handy.