7

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
tshepang
  • 12,111
  • 21
  • 91
  • 136
user2426277
  • 71
  • 1
  • 3
  • 1
    That only works for the checkout you have. If you check this out again to another folder, that checkout will contain that file and the metadata associated with it. – Sameer Singh Jul 11 '13 at 09:24

2 Answers2

8

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.

Community
  • 1
  • 1
n611x007
  • 8,952
  • 8
  • 59
  • 102
  • Sparse directories are really good when comes to hide unused branches. I like to work with the whole working tree checked out. The [svnbook](http://svnbook.red-bean.com/en/1.7/svn.advanced.sparsedirs.html) says that you can see checkout depth of a directory using `svn info`. I can't see any way to get a list of excluded directories, though. – Piotr Siupa Oct 24 '17 at 20:20
  • This does not work anymore for me. I have a checkout, I want to hide directories, the above method does not work. "svn up" will again check out everything, "svn st" will report the deleted files as missing. – peschü Jan 14 '20 at 19:32
-5

It should be as simple as:

svn delete test.txt
svn ci -m 'Delete test.txt.'
cforbish
  • 8,567
  • 3
  • 28
  • 32