Remove Command
The remove command removes files and directories from a CVS repository.
Removing a file
Suppose, there is a file named try.txt in your repository as well as your working directory and you want to remove it from the repository. Let's see what the below command will do.
$ cvs remove try.txtThe output will be:
cvs remove: file `try.txt' still in working directory cvs remove: 1 file exists; remove it firstWhy did we get this output? The answer is that before you delete a file from the repository, you need to make sure to delete it from your working directory first. We use rm command for this.
$ rm try.txt $ cvs remove try.txtWe will get a message like this:
cvs remove: scheduling `try.txt' for removal cvs remove: use `cvs commit' to remove this file permanentlyThe remove command schedules a file to be removed but you need to commit it to actually delete it. So, the complete set of commands to remove the file, try.txt from the repository is:
$ rm try.txt $ cvs remove try.txt $ cvs commit -m "File is removed" try.txtRemoving a directory
There is no such command in CVS to delete an entire directory from the repository. But, you can do so by first removing all the files in that directory and then change the current directory to one level above and then run the update command with the -P option, which removes the empty directories.
$ rm new1.txt $ rm new2.txt $ cvs remove new1.txt new2.txt $ cvs commit –m "Removed files" new1.txt new2.txt $ cd $ cvs update –PThe above commands will delete the directory containing the files, new1.txt and new2.txt.
Does remove command deletes the file from the repository?
No. The file is not physically deleted. It is only flagged as deleted and it can be recovered by using the combination of add and commit command.
Options of the remove command
-f
This option is used to forcibly delete the file physically as well.
