If I run svn rm file
, the file is removed from the local working copy.
What I do now is:
$ cp file file2 $ svn rm file $ svn ci $ mv file2 file
How do I avoid svn also deleting the local file when using svn rm
?
To remove a file from a Subversion repository, change to the directory with its working copy and run the following command: svn delete file… Similarly, to remove a directory and all files that are in it, type: svn delete directory…
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With