Commonly used Commands in CVS
Here are some of the commonly used CVS commands.
To use a CVS repository you first need to set the CVSROOT environment variable to the project data base.
1. How to add a new file or directory in the CVS Database ?
cvs add <filename>
This command adds the specified file name in the CVS database. Once this file name is added, you need to “checkin” the file so that the actual file contents are updated in the database.
This command is used only once with a file/directory at first time.
2. How to checkin a file to the CVS database?
After adding a filename, we need to put the whole file into the database using following commands.
cvs checkin -m “” <filename>
cvs ci -m “” <filename>
cvs commit -m “” <filename>
-m : is a message option to specify any short information about the change You can check in as many as versions of a file and each check in gives you a new version number
3. How to check out a file from CVS Database?
cvs checkout “filename”
cvs co “filename”
Here the filename can be a file or a directory (if u want to checkout all files in the directory)
By default above command will always get you the latest version of the file.
If you want to get a specific version of file, please use the version number as following:
cvs co -r <version> <file name>
4. How to update files in your working environment to latest in CVS database?
Once you have checked out a database or a set of files/directories, there could be other users who also modify same or different files as part of the database which you would want to reflect in your workspace at regular intervals.
For this, we need to use the “cvs update” command which works similar to checkout command
Following command brings the required file/files which are updated in the CVS but not synced with your working environment.
cvs update < filename>
cvs up <filename>
6. What is tagging a how to tag a file ?
Tagging is a very useful feature given in the version control system. While working on a shared project data base in a group of people, you might want to checkpoint the database at regular intervals – may be when the project reaches intermediate milestones. This is possible by associating a tag for all the files in the data base which might have different versions.
You can provide a same tag to all the relevant files from different versions and you can retrieve them anytime by supplying the tag name.
cvs tag <filename>
7. How to check out a set of files from a given tag?
If you want to get all the files from the repository with a given tag, you can use following command
cvs co -r <filename>
8. How to delete a tag :
Following command is used to delete a tag info from a file.
cvs rtag -d <tagname> <filename>
9. How to find difference between files from two different versions
If you want to know the difference in the files form two deferent cvs versions, you can use following command
cvs diff -r <version1> -r <version2> <filename>
10. How to see t he CVS version information associated with a file
The see the log messages, which was given at the time of check in with -m option can be seen by
cvs log <filename>
To see the status of the file, whether is in sync with the database file of locally modified can be seen using –
cvs status <filename>
To view the tag information with the status use following command
cvs status -v <filename>