Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the file is already in an SVN working copy, update just that target with svn update path/to/file. If you do not have a working copy, SVN cannot check out a lone file as a versioned working copy; use a sparse checkout to keep SVN metadata, or svn export if you only need an unversioned copy.

Update one file in an existing working copy

From the working-copy root, run:

svn update path/to/file

Replace path/to/file with the file’s path relative to your current directory, or provide its path from elsewhere in the working copy. The command updates that target from the repository while respecting the working copy’s sparse depth. Changes already made locally can interact with incoming changes, so check the file first:

svn status path/to/file

Review any local modifications before updating. Apache’s quick-start documentation describes svn update as the command for synchronizing a working copy with repository changes and recommends updating before committing.

Can you check out a single versioned file?

No. Subversion does not support checking out a lone file as a versioned working copy: checkout operates on directory structures. A versioned working copy includes SVN metadata that allows commands such as svn update to work on tracked paths. The Subversion FAQ states that a single-file checkout is not supported.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a sparse checkout to avoid populating the whole tree

If you need a small working copy that retains SVN metadata, check out a directory at empty depth, then add only the parent directories and file you need. For example:

svn checkout --depth=empty https://svn.example.com/repos/project/trunk project-wc
cd project-wc
svn update --depth=empty path/to/parent
svn update path/to/file

Replace the example repository URL and paths with your own. The first command creates a working copy of the trunk directory without populating its children. The second creates or updates the parent directory at empty depth; the final command retrieves the requested file.

Subversion 1.5 introduced depth options for checkout, switch, and update. The documented depth choices control how much of a directory tree is populated:

Depth What it populates
empty The directory itself; no files or subdirectories are pulled in.
files Files directly inside the directory, but not its subdirectories.
immediates Immediate files and directories; newly added subdirectories remain at empty depth.
infinity The full tree recursively, equivalent to normal full-depth behavior.

These definitions and the behavior of sparse updates are described in the Subversion 1.5 release notes. The update API documentation also describes target depth and the make_parents option, which can create missing parent directories at empty depth.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sparse updates preserve existing depth settings, and increasing depth can populate more of the tree. The 1.5 release notes do not describe a general deselection interface, so plan the sparse layout before expanding it. For exact options supported by your installed client, run svn help update. The sparse directories guide describes svn update as the primary way to configure sparse working copies.

Choose the command for what you need

Need Command Result
Refresh a file already in a working copy svn update path/to/file Updates the target, subject to sparse depth and conflicts.
Create a small versioned working copy svn checkout --depth=empty REPO/subtree wc, then svn update path/to/file Keeps SVN metadata while populating only requested paths.
Get one unversioned file svn export REPO/path/file local-file Copies file contents without creating a versioned working copy.
Read a historical repository revision svn cat -r REV REPO/path/file Prints the file contents without changing your working copy.

Export a file when you do not need SVN metadata

To obtain a file without creating a working copy, use svn export:

svn export REPOSITORY_URL/path/to/file local-file

This retrieves the file’s contents without SVN metadata, so the result is not a versioned working copy and cannot be updated with svn update. The Subversion FAQ identifies export as the alternative when a single file is needed without a working copy.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Inspect an older revision without changing your working copy

To read a file at a particular repository revision, use svn cat with the revision and repository URL:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
The SQL Programming Language: .
  • Used Book in Good Condition
svn cat -r REV REPO/path/to/file

Replace REV with the revision number and the path with the repository file path. The command writes the file contents to the terminal and leaves the working copy unchanged. See the sparse directories guide for this historical-inspection use case.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.