Removing and restoring files

When you remove a file from the repository, CVS puts it into the attic. Each directory in the repository has a subdirectory called Attic. You can't check the Attic out into your sandbox, but you can examine its contents through a web interface to CVS.

To delete a file (say, phoenix.c):

  1. Remove the file from your sandbox:
    rm phoenix.c
  2. Remove the file from the repository:
    cvs remove phoenix.c


    cvs rm phoenix.c
  3. Commit your changes.

If you later need to restore the file:

  1. Determine the last revision number for the file:
    cvs log phoenix.c | less
  2. Go to the base directory for your sandbox (e.g., ~/cvs) and get the file, specifying the last version number minus one. For example, if the deleted version of phoenix.c was 1.4, you need to get version 1.3:
    cvs checkout -r 1.3 my_project/phoenix.c


    cvs get -r 1.3 my_project/phoenix.c

    The -r option sets a sticky tag.

  3. Go back to the directory where you want the file to go, and rename the file or move it out of the way, then clear the sticky tag:
    mv phoenix.c save_phoenix.c
    cvs update -A
  4. Rename the file or move it back, and then add it to the repository:
    mv save_phoenix.c phoenix.c
    cvs add phoenix.c
  5. Commit your changes.