102

Can I ignore a folder on svn checkout? I need to ignore DOCs folder on checkout at my build server.

edit: Ignore externals isn't an option. I have some externals that I need.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Zote
  • 5,343
  • 5
  • 41
  • 43
  • Check out this: http://stackoverflow.com/questions/116074/how-to-ignore-a-directory-with-svn – hephestos Mar 02 '11 at 14:10
  • Does this answer your question? [How do I ignore a directory with SVN?](https://stackoverflow.com/questions/116074/how-do-i-ignore-a-directory-with-svn) – Gautier Dec 20 '19 at 13:59

11 Answers11

106

You can't directly ignore folders on a checkout, but you can use sparse checkouts in svn 1.5. For example:

$ svn co http://subversion/project/trunk my_checkout --depth immediates

This will check files and directories from your project trunk into 'my_checkout', but not recurse into those directories. Eg:

$ cd my_checkout && ls
bar/ baz foo xyzzy/

Then to get the contents of 'bar' down:

$ cd bar && svn update --set-depth infinity
Jon Topper
  • 3,097
  • 1
  • 20
  • 15
  • Note: there was a bug in some 1.5 versions that prevented this with `svn: Shallowing of working copy depths is not yet supported` – gcb Jan 26 '12 at 22:07
82

Yes you can using SVN 1.6. You will need to do a checkout first then mark the folder for exclusion then delete the unwanted folder.

svn checkout http://www.example.com/project
cd project
svn update --set-depth=exclude docs
rm -fr docs

From now on any updates to the working copy won't repopulate the docs folder.

See http://blogs.collab.net/subversion/2009/03/sparse-directories-now-with-exclusion/ and http://subversion.apache.org/docs/release-notes/1.6.html#sparse-directory-exclusion for more details.

Tom

tommy_turrell
  • 829
  • 6
  • 2
9

With versions prior to 1.5 I have found that if you checkout only the top most folder and then selectively update, from then on updates only effect what you have checked out. Ie.

svn co -N foo
cd foo
svn up -N bar
svn up

The -N flag makes the operation non-recursive. The above will not check out anything else at the foo level, eg. say there is a folder lala, the final svn up will not check out that folder, but it will update bar.

But at a later time you can svn up lala and thus, add it to the checkout.

Presumably this also works with 1.5.

mxcl
  • 26,392
  • 12
  • 99
  • 98
6

This is in TortoiseSVN client 1.7.1 (might be available in some older versions as well):

  • SVN checkout --> Select URL of repository

  • Click on "Checkout Items" (under Checkout Depth) and select only the folders required!

gammay
  • 5,957
  • 7
  • 32
  • 51
4

Yes, Subversion 1.5 has a feature called Sparse checkouts that can do exactly this sort of thing.

misterManSam
  • 24,303
  • 11
  • 69
  • 89
Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • 2
    From reading that, it looks like sparse checkouts only limit the depth of a checkout. They can't ignore one particular folder. – John Millikin Oct 10 '08 at 20:04
  • Sure, you might have to do a little extra legwork, like limit the depth of the parent folder with --depth immediates, then check out all the other folders except the one you would like to ignore. The point is, the tools are there if you need to use them. – Greg Hewgill Oct 11 '08 at 05:45
  • I appreciate the mention of SparseCheckouts, and it is interesting for sure, but this response does not address the original question. Sure, I can check out one file at a time, and that will result in having local copies of specific files I want, but what a pain in the ass to have to do each individually. I believe the author of this question is asking about ignoring a specific folder, not depth of x folders, and allow the computer do the work - the same work you are recommending could be accomplished manually. – barrypicker Nov 05 '12 at 17:32
  • The 1.6+ versions provide the added ability to ignore folders and more control general of what to include/exclude in a working copy (where v1.5 is very limited in this) http://svnbook.red-bean.com/en/1.7/svn.advanced.sparsedirs.html – FruitBreak Aug 24 '15 at 20:52
4

You could put the docs folder in an external repository and then use svn checkout --ignore-externals.

John Millikin
  • 197,344
  • 39
  • 212
  • 226
  • This is what we ended up doing to skip some pre-built components in a previous job. – Mark Bessey Oct 10 '08 at 21:02
  • 2
    I don't understand what the `external repository` means. Can you explain it? – Victor Dec 02 '14 at 08:38
  • An external repository just means a different repository. You can set SVN properties on the original repository to bring in external content. The property is called "externals", hence that term. – Overbyte Aug 03 '22 at 15:39
3

I found this question looking for a way to check out the WebKit sources while excluding the regression tests. I ended up with the following:

svn checkout http://svn.webkit.org/repository/webkit/trunk WebKit \
  --depth immediates

cd WebKit
find . \
  -maxdepth 1 -type d \
  -not -name '.*' \
  -not -name '*Tests' \
  -not -name 'Examples' \
  -not -name 'Websites' \
  | (while read SUBDIR; do svn update --set-depth infinity "$SUBDIR"; done)

Note you can change the exclusions as you see fit, but .* is recommended to skip the working directory (which is already up to date) and all of the .svn directories.

rgov
  • 3,516
  • 1
  • 31
  • 51
2

I have recently resolved the same task. The idea is to get the immediate list of folder/files under the repository exclude the entries you need, then check out the remaining folders and update the immediate files if any. Here is the solution:

    # Path to the svn repository to be checked out
rpath=https://svn-repo.company.com/sw/trunk/ && \
    # This files are to be excluded (folders are ending with '/')
    # this is a regex pattern with OR ('|') between enties to be excluded
excludep='docs_folder/tests_folder/|huge_folder/|file1|file2' && \
    # Get list of the files/folders right under the repository path
filtered=`svn ls $rpath | egrep -v $excludep` && \
    # Get list of files out of filtered - they need to be 'uped'
files=`echo $filtered | sed 's| |\n|g' | egrep '^.*[^/]$'` && \
    # Get list of folders out of filtered - they need to be 'coed'
folders=`echo $filtered | sed 's| |\n|g' | egrep '^.*[/]$'` && \
    # Initial nonrecursive checkout of repository - just empty
    # to the current (./) working directory
svn co $rpath ./ --depth empty && \
    # Update the files
svn up $files &&\
    # Check out the all other folders finally.
svn co `echo $folders | sed "s|\<|$rpath|g"`

Change to source working directory. Copy the commands. Paste. Change appropriate URL and exclude pattern. Run the command.

Thanks,

bv.
  • 85
  • 6
  • 1
    hey what's 6 years for developers? On your last line you have $ubrpath. Where is that set? – D-Klotz Feb 10 '16 at 15:19
  • 1
    @D-Klotz, thank you, that should be $rpath instead, which in turn is set to the repository path.
    Sorry for one year late
    – bv. Feb 13 '17 at 20:14
1

No, ignore is only for adding files.
You can use sparse checkouts (if you use svn 1.5)

Peter Parker
  • 29,093
  • 5
  • 52
  • 80
1

As a few others have mentioned, you can just use svn:externals properties and then the --ignore-externals option when you checkout. One thing to note, however, is that svn:externals does not necessarily need to refer to another repository. It can be a reference to some other folder in the same repo.

Nik Reiman
  • 39,067
  • 29
  • 104
  • 160
0

The best way I have seen is to check out a zero depth version and then go into the directories you need to change and update the depth.

Checking out a zero depth folder

$ svn co svn://subversion/project/my_project_dir --depth immediates

Then going into the working folders and adding depth

$ cd my_project_dir
$ cd working_dir && svn update --set-depth infinity

Update as many folders as you need to work on!