Assume that you have a directory under subversion control, that contains some files and tons of subdirectories, like that:
file1.txt
file2.txt
file3.txt
dir1/
dir2/
dir3/
dir4/
:
dirXX/
Now you need the files and some of the dirs, but not all of them. This can be done with SVN. Just make the checkout non-recursive:
svn checkout -N <URL>
This checks out only the first directory and the files inside. No subdirectories are included. Even if you go into the checkout directory and run a "svn up
", it will only update the files checked out previously, it will not add the directories. You can now selectively add the directories you need by explicitly updating those. E.g. if you need dir2 and dir4 only, you can go into the checkout directory and execute
svn up dir2
svn up dir4
If you run a generic "svn up
" in the future, it will only update the files and those two directories, it will not add any of the other directories.
Now the problem: What if I decide at any later point that I don't need dir2 any longer? How do I get rid of it? There seems no way of doing so, other than deleting the whole checkout and start over from scratch.
When you just delete dir2, the next "svn up
" will bring it back, as "svn status
" of course shows it as missing now ("!" in front of its name). Running a "svn remove
" will remove it of course, but on next commit it will also remove it from the repository, which must not happen.
Even the new sparse directory ("shallow checkout") feature of SVN 1.5 is of no use here:
Subversion 1.5's implementation of shallow checkouts is good but does not support a couple of interesting behaviors. First, you cannot de-telescope a working copy item. Running svn update --set-depth empty in an infinite-depth working copy will not have the effect of discarding everything but the topmost directory—it will simply error out.
- http://svnbook.red-bean.com/en/1.5/svn.advanced.sparsedirs.html
Is this complete impossible with SVN? Anyone ever came up with a clever work-a-round to that?
Just creating the checkout directory (without SVN) and then checking out the individual subdirectories from the repository directly as subdirectories to this directory will work for the directories: now every directory is a checkout of its own, can be updated and once not needed any longer, you can just delete it. However, how do I get the files then (e.g. file1.txt)? SVN does not allow to checkout individual files, you can only checkout whole directories.