Removing files

Directories change. New files are added, and old files disappear. Still, you want to be able to retrieve an exact copy of old releases.

Here is what you can do to remove a file, but remain able to retrieve old revisions:

When you commit the removal of the file, cvsnt records the fact that the file no longer exists. It is possible for a file to exist on only some branches and not on others, or to re-add another file with the same name later. cvsnt will correctly create or not create the file, based on the -r and -D options specified to checkout or update.

cvs remove [options] files ... Schedule file(s) to be removed from the repository (files which have not already been removed from the working directory are not processed). This command does not actually remove the file from the repository until you commit the removal. For a full list of options, see the section called “remove--Remove files from the working directory”.

Here is an example of removing several files:

$ cd test
$ rm *.c
$ cvs remove
cvs remove: Removing .
cvs remove: scheduling a.c for removal
cvs remove: scheduling b.c for removal
cvs remove: use 'cvs commit' to remove these files permanently
$ cvs ci -m "Removed unneeded files"
cvs commit: Examining .
cvs commit: Committing .

As a convenience you can remove the file and cvs remove it in one step, by specifying the -f option. For example, the above example could also be done like this:

$ cd test
$ cvs remove -f *.c
cvs remove: scheduling a.c for removal
cvs remove: scheduling b.c for removal
cvs remove: use 'cvs commit' to remove these files permanently
$ cvs ci -m "Removed unneeded files"
cvs commit: Examining .
cvs commit: Committing .

If you execute remove for a file, and then change your mind before you commit, you can undo the remove with an add command.

$ ls
CVS   ja.h  oj.c
$ rm oj.c
$ cvs remove oj.c
cvs remove: scheduling oj.c for removal
cvs remove: use 'cvs commit' to remove this file permanently
$ cvs add oj.c
U oj.c
cvs add: oj.c, version 1.1.1.1, resurrected

If you realize your mistake before you run the remove command you can use update to resurrect the file:

$ rm oj.c
$ cvs update oj.c
cvs update: warning: oj.c was lost
U oj.c

If you realize your mistake after running the commit command you can use add to resurrect the file:

$ cvs remove foo.c
cvs remove: scheduling foo.c for removal
cvs remove: use 'cvs commit' to remove these files permanently
$ cvs ci -m "Removed unneeded files"
cvs commit: Examining .
cvs commit: Committing .
$ cvs add foo.c
cvs add: foo.c, version 1.5, resurrected
U foo.c
cvs add: use 'cvs commit' to add this file permanently
$cvs ci -m "Oops shouldn't have deleted that..."
cvs commit: Examining .
cvs commit: Committing .

When you remove a file it is removed only on the branch which you are working on (Chapter 6, Branching and merging). You can later merge the removals to another branch if you want (the section called “Merging can add or remove files”).