Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a file from version control without deleting it?

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?

like image 239
Juanjo Conti Avatar asked Aug 26 '10 21:08

Juanjo Conti


People also ask

How do I delete a file from svn version control?

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…


2 Answers

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.

like image 54
Andres Jaan Tack Avatar answered Oct 14 '22 00:10

Andres Jaan Tack


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.

like image 26
Albrecht Weinert Avatar answered Oct 13 '22 23:10

Albrecht Weinert