Using Subversion Sparse Checkout to Retrieve Selected Directories
Learn how to use Subversion’s sparse checkout to check out only the directories you need, reducing disk usage and update time while keeping the ability to expand or shrink the view later.
07 Jun 2026, 12:08 UTC

Desired outcome
Create a working copy that contains only the directories you need from a large Subversion repository, saving disk space and reducing update time.
Prerequisites
- Subversion client version 1.5 or later installed.
- Read access to the repository URL (e.g.,
https://svn.example.com/repo). - Basic familiarity with
svn checkoutandsvn updatecommands.
Procedure
- Perform an initial sparse checkout that brings in only the top‑level directories you want to work with. For example, to check out just the
trunkand a specific subdirectorysrc/lib: - Navigate into the working copy and set the depth for the subdirectory you actually need:
- If you later need additional directories, adjust their depth similarly:
- To reduce the working copy again, set a shallower depth:
svn checkout --depth=immediates https://svn.example.com/repo/trunk my-working-copyThis creates my-working-copy containing the trunk directory but with all its immediate children set to depth empty (i.e., only their names are present).
cd my-working-copy/trunk
svn update --set-depth=infinity src/libNow src/lib and all of its nested contents are fully populated, while other directories under trunk remain absent.
svn update --set-depth=infinity src/tools
svn update --set-depth=immediates docs # keep only the docs folder namesvn update --set-depth=empty src/tools # removes src/tools contentsExpected checks
- After each
svn update --set-depthrun, verify the reported depth with:
svn info --depth=immediates src/libThe output should show Depth: infinity for fully expanded directories or Depth: empty for collapsed ones.
svn status to ensure no unexpected modifications appear; omitted items will show as ! only if they were deliberately removed by a depth reduction.svn list -R src/libRecovery options
Changing depth from deeper to shallower removes the omitted files from the working copy. If you realize you need those files again, simply run an svn update --set-depth=infinity on the affected directory to restore them. No repository data is lost; only the working copy is modified.
Limitations
- Build scripts that expect the full tree may fail if they reference files omitted by a sparse checkout. Verify script compatibility before relying on a reduced working copy.
- Depth properties are stored per‑directory; mixing inconsistent depths (e.g., a parent set to
emptywhile a child isinfinity) can lead to confusing states. Keep depth settings hierarchical and update parents before children when expanding.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.