Last Updated: February 25, 2016
·
5.132K
· groodt

Subversion sparse checkouts

In Subversion 1.5 and greater, there is a great feature that allows you to perform sparse checkouts of a repository. This is really useful if you have a large repository and you only want to work on a section of it.

It also means that you can checkout the skeleton of the whole tree, including tags and branches and only pull-down the content as required.

As an example:

svn checkout http://svn.apache.org/repos/asf/subversion --depth=immediates

cd subversion/trunk

svn update --set-depth infinity

cd ../tags

svn update --set-depth immediates

cd 1.7.7

svn update --set-depth infinity

The example above, checks out a skeleton of the empty directories at the top level of the Apache Subversion repository. I then change into the subversion/trunk directory and do an 'svn update' that pulls down all the content under the 'trunk'. The rest of the repository remains a sparse checkout. I then change into the 'tags' directory and pull down the empty folders of all the tags that have been created. I then change into the '1.7.7.' tag and pull down the actual content by setting the depth to infinity.

You can imagine this would be handy if you want to check if a change exists in a certain tag, or you want to work on a particular branch when there are many branches.

Note the pattern above, when you checkout a repository, you use the --depth option. When you update, you are able to change the sticky depth setting using the --set-depth option.

For more details of this feature, checkout the docs:
http://svnbook.red-bean.com/en/1.5/svn.advanced.sparsedirs.html