51

I have an SVN project with tree like this:

/project
    /dir1
        /subdir1
           -file1
           -file2
            .....
        -file1
        -file2
        .....
    /dir2
        -file1
        -file2
        .....
    /dir3
        /subdir1
           -file1
           -file2
            .....
        /subdir2
           -file1
           -file2
            .....
        /subdir3
           -file1
           -file2
            .....
        /subdir4
           -file1
           -file2
            .....
    /dir4
        -file1
        -file2
        .....
-file1
-file2

I need to checkout

  • all files from /project
  • full /dir1
  • full /dir2
  • full /dir4
  • From /dir3 I need only /subdir1 and /subdir3

Can I checkout these files/folders using svn commandline with some kind of depth? If so how can I do it? Can I add subdir2 to dir3 after a checkout? How can I update working copy created this way? Will normal "svn up" command update only these folders or full update of project will be performed?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Pablo notPicasso
  • 3,031
  • 3
  • 17
  • 22

2 Answers2

82

What you need is called sparse checkout.

In your case you can:

svn co --depth files file:///project project
cd project
svn up --set-depth infinity dir1 dir2 dir4
svn up --set-depth empty dir3
svn up --set-depth infinity dir3/subdir1 dir3/subdir3

Can I add subdir2 to dir3 after a checkout?

Yes: svn up --set-depth infinity dir3/subdir2

How can I update working copy created this way? Will normal "svn up" command update only these folders or full update of project will be performed?

Yes, svn up will update only these files and folders, that is update depth will be preserved.

ks1322
  • 33,961
  • 14
  • 109
  • 164
  • Thanks a lot.So if I understand if a new folder (for example dir5) will be added to project it will not be updated. Am I right? – Pablo notPicasso Jul 26 '12 at 06:17
  • Yes, parent folder of dir5 has depth set to `files`, so new files will be updated, but not new folders. – ks1322 Jul 26 '12 at 07:43
  • 3
    If you want to automatically add new top-level subdirs, using `--depth immediates` instead of `--depth files` should do the trick. – Frank Schmitt Nov 11 '13 at 12:06
  • Now I know where I did wrong in past - I used `co` again instead of `up` in your example, thanks. – Betlista Sep 25 '14 at 10:20
  • Just found that `--set-depth` is required when the directory you are trying to update was created using `--depth immediates` (as its depth property is set to 'empty' as can be seen by `svn info`) – Apteryx Mar 14 '16 at 18:04
1
  1. svn up --set-depth empty file/folder path
  • => it will delete the file from your system**
  1. svn up --set-depth infinity file/folder path
  • => it will regenerated the file from svn server to your local system**
Jean-Francois T.
  • 11,549
  • 7
  • 68
  • 107