Delete file from the working copy only but not from the repository

svn

Solution

lallafa reports a good method, based on something called sparse directories:

svn update --set-depth exclude <folder-to-delete>

- nice

- easy

- works on files

not good if:

- I guess won't help you avoid checking out GBs of data you have (although you could try this.)

- doesn't work on switched directories (may or may not with a little work, not tested)

- on large directories, not a very good idea. od_m3 says that on a 190 GB working copy, with `svn 1.6` this method tooks 1 hours, but on `svn 1.7` it tooks more than 50 hours. This was in 2011.

added from source:

if you later want to use that directory again, you can do

svn update --set-depth=infinity <folder-to-delete>

I wish I knew how can I list directories already "excluded" this way, because `st` won't show them. :D

another method from same source by someone called 'Mike5' (or jed/jeds) that works on directories:

for every directory you want to avoid updating, do

svn switch --ignore-ancestry http://dummy/exists/but/empty_folder some_folder

- replace `some_folder` with the folder you want to ignore.

- also replace `http://dummy/exists/but/empty_folder` with an existing path in your repository which is an empty directory, will never be updated nor deleted - supposedly created and dedicated for this purpose.

By this, you will achieve:

- switched directories not updating any more in the working copy

- no changes to the actual repository

You will not achieve:

- anything on files

- the directory won't disappear/be deleted (from file listing)

- getting rid of initial checking out of these directories, unless you do a checkout for 'immediates' with `--depth`, first, do this, and then continue the checkout (not tested).

- I guess you cannot get rid of downloading GBs of data you already have (not tested).

It is also a good idea to use `svn propset svn:ignore "*" empty_folder` on the dedicated empty directory, so noone can commit anything to it.

Problem

Since I could not find the answer of the above question anywhere in the web, I come with the solution myself. It's a manual process but I couldn't find any other standard solution. So here it is: Suppose you want to delete the file test.txt from directory work. Now if you delete test.txt forcefully by rm -rf test.txt command then on the next svn up on the work dir (or any of its parent-directories), the file will be restored. So the trick is to delete it from .svn/entries file, as well. Thus the complete sequence of commands for deleting test.txt only from working copy is: ``` cd work rm -rf test.txt svn st #it shows ! sign beside test.txt which means that #in the next **svn up** it will be restored chmod u+w .svn/entries vi .svn/entries #delete the lines associated with test.txt #you need to delete the following 3 lines from .svn/entries #test.txt #file #^L svn st #it doesn't report test.txt anymore ```

Original source

Related problems