How to remove a file from version control without deleting it?
Removing a file from SVN without deleting it locally nowhere is a common problem. One prominent example is the file .classpath in an Eclipse project. Putting this configuration file under SVN is marvellous as long as all machines used in the project have the same Eclipse and Java installation. Once this condition is violated commits start to break other Eclipse projects. This is the point one has to remove a file from SVN without deleting ist anywhere.
svn rm --keep-local .classpath
does the job perfectly on one machine and at that point in time.
Problem is other machines may lose that file (on update) or resurrect it (on commit). SVN's flaw is neither to handle --keep-local
in the repository nor to propagate it to other working copies. Hence on all other machines above command has to be executed — best before any commit or update.
This, of course, will work 90%, at best. Deletes and re-versionings will happen out of a sudden. My solution is to have every machine, I have direct or indirect access to, do
svn rm --keep-local .classpath
copy .classpath .classpath-nameOfTheMachine
svn add .classpath-nameOfTheMachine
This is so outright ugly to be hardly called a "solution". Nevertheless it always allowed quick repairs of any later accidents.
You want the --keep-local
command-line option. This removes the file from version control without removing it from your filesystem.
$ svn rm --keep-local my_important_file
Note: The --keep-local
only affects the svn rm
of your copy. Other users may have their own local copy of the file deleted unless there is a conflict between their local copy and the repository due to changes they have made. This may not be the desired outcome. See comments below.