Using RCS to Keep Track of Changes to File

The principle benefit of RCS for most users is that it provides an easy way to view or obtain any previous version of a file that is revised over time. If an RCS maintained file is accidentally deleted or badly modified, then backup copies of any previous version are readily available.

The very basics

Suppose "grades" is a file used to store grades for a course and that it is updated weekly. It is important that a recent backup copy of this file always be present in case it ever becomes corrupted. The best way to ensure a backup is always present is to type the following command each time before editing the file.

  > ci -l grades 

The "ci" (check-in) command stores a backup of "grades" in a file called "grades,v", though that file should never be accessed except by using RCS commands. "grades,v" is created the first time ci is run on a file, and is appended to on later check-ins. When ci is first run on a file, ci will ask for a description of the file. A description can be entered, if desired, and is completed by typing a line consisting of only a period (as the ci command instructs). Furthermore, on each successive occasion that a file is checked in, ci will ask for a summary of the changes, which is entered just like the original description.

If "grades" is ever corrupted or deleted, the command "co -l grades" (check-out) can be used to retrieve the most recently checked in version.


Just beyond the basics

The original file is assigned a version number 1.1, and successive checked-in versions are numbered 1.2, 1.3, 1.4, etc. To view a log of all the changes and change descriptions for the file "grades", type

  > rlog grades 

To view revision 1.2 of the "grades" file, type

  > co -p -r1.2 grades
  OR
  > co -p -r1.2 grades | less 

To restore revision 1.4 of the "grades" file, type

  > co -l -r1.4 grades 

To see the changes between the working copy of "grades" and the last checked-in version, type

  > rcsdiff grades 

To see the changes between the working copy of "grades" and revision 1.4 of "grades", type

  > rcsdiff -r1.4 grades 

Using a RCS directory

To avoid clutter, and since the RCS files with the ",v" extension are never directly accessed anyways, it is convenient to create a directory names "RCS" for the ",v" files. If such a directory exists in the current directory, then RCS will automatically create and maintain the ",v" files inside it.