

How do I get around this issue when using Subversion?

We have this folder in Subversion where we keep all our images. I just want to check out one file (image) from that. This folder is really big and has ton of other stuff which I don't need now.

  • You can do it the other way. Log in into the production server and svn up to your local directory on your computer. – Neocortex Dec 12 '14 at 11:01

19 Answers 19


The simple answer is that you svn export the file instead of checking it out.

But that might not be what you want. You might want to work on the file and check it back in, without having to download GB of junk you don't need.

If you have Subversion 1.5+, then do a sparse checkout:

svn checkout <url_of_big_dir> <target> --depth empty
cd <target>
svn up <file_you_want>

For an older version of SVN, you might benefit from the following:

  • Checkout the directory using a revision back in the distant past, when it was less full of junk you don't need.
  • Update the file you want, to create a mixed revision. This works even if the file didn't exist in the revision you checked out.
  • Profit!

An alternative (for instance if the directory has too much junk right from the revision in which it was created) is to do a URL->URL copy of the file you want into a new place in the repository (effectively this is a working branch of the file). Check out that directory and do your modifications.

I'm not sure whether you can then merge your modified copy back entirely in the repository without a working copy of the target - I've never needed to. If so then do that.

If not then unfortunately you may have to find someone else who does have the whole directory checked out and get them to do it. Or maybe by the time you've made your modifications, the rest of it will have finished downloading...

| improve this answer | |
  • 13
    The really simple solution is to access the repository with a web browser. – dolmen Jul 9 '10 at 8:32
  • 11
    @dolmen - Assuming no need to modify the file, perhaps (and assuming a web interface is running for that repository). I use command-line SVN, so for me, it's simpler to use svn export than it is to use the web interface, if I know what file I want. The questioner already uses SVN, so I guess it depends what client and whether that client makes it easy to use svn export. I do find the web interface better for browsing than svn ls, though :-) – Steve Jessop Jul 10 '10 at 15:32
  • 2
    SmartSVN Client will lock individual files if your Subversion Server supports it. And there are hooks which require check outs must be done before a binary/executable file can be checked in. It doesn't really make sence to have two people modify a binary fine and have those changes merged together. These may be new features that weren't available when this question was asked. – TamusJRoyce Aug 14 '11 at 16:30
  • @Tamus: "It doesn't really make sense" agreed, but in the cases I describe the merge is just to get the new version back into the original location. It's not expected that the binary file has been modified in the target of the merge. So the file itself doesn't need any "merging" beyond replacing the old version with the new one, it's just what SVN calls it and it records where the changes came from for future reference. You're right, conflict-avoidance could be enforced by locking the file for the duration. – Steve Jessop Aug 18 '11 at 0:34
  • 1
    TortoiseSVN can check out individual files. I believe it does the same thing behind scenes to achieve that. – Mike Starov Mar 14 '13 at 21:55

Try svn export instead of svn checkout. That works for single files.

The reason for the limitation is that checkout creates a working copy, that contains meta-information about repository, revision, attributes, etc. That metadata is stored in subdirectories named '.svn'. And single files don't have subdirectories.

| improve this answer | |
  • 2
    Caveat: Extremely old versions of svn won't do single file exports. – Mladen Jablanović Dec 29 '11 at 14:47
  • 5
    This is the superior method if you just want to grab the latest version of a particular script as part of a deploy, or something. – william.berg Aug 2 '13 at 11:44
  • 1
    That caveat was a stretch even back in 2011 but extremely old versions can do svn cat $url_to_file_in_repo > $local_file_name. – cprn Jun 12 '19 at 8:58

Use svn cat or svn export.

For that, you don't need to fetch the working directory, but you will not be able to commit any changes you make. If you need to make changes and commit them, you need a working directory, but you don't have to fetch it completely. Checkout the revision where the directory was still/almost empty, and then use 'svn cat' to extract the file from HEAD.

| improve this answer | |
  • svn cat svn://.../my_file.txtwas exactly what I was looking for. I work in an svn:// only (no http://) repository, and it looks the newest websvn interfaces doesn't provide a raw file download (or we have it mis-configured or I am blind). Easier to do this way than checkout+up just for downloading a file. – ribamar Nov 27 '15 at 11:10

If you want to view readme.txt in your repository without checking it out:

$ svn cat http://svn.red-bean.com/repos/test/readme.txt
This is a README file. You should read this.

Tip: If your working copy is out of date (or you have local modifications) and you want to see the HEAD revision of a file in your working copy, svn cat will automatically fetch the HEAD revision when you give it a path:

$ cat foo.c
This file is in my local working copy and has changes that I've made.

$ svn cat foo.c
Latest revision fresh from the repository!


| improve this answer | |
  • You can also directly use any HTTP client. Your web browser, or a command-line tool such as curl or wget. – dolmen Jul 9 '10 at 8:31

A TortoiseSVN equivalent solution of the accepted answer (I had written this in an internal document for my company as we are newly adopting SVN) follows. I thought it would be helpful to share here as well:

Checking out a single file: Subversion does not support checkout of a single file, it only supports checkout of directory structures. (Reference: http://subversion.tigris.org/faq.html#single-file-checkout). This is because with every directory that is checked out as a working copy, the metadata regarding modifications/file revisions is stored as an internal hidden folder (.svn/_svn). This is not supported currently (v1.6) for single files.

Alternate recommended strategy: You will have to do the checkout directory part only once, following that you can directly go and checkout your single files. Do a sparse checkout of the parent folder and directory structure. A sparse checkout is basically checking out only the folder structure without populating the content files. So you checkout only the directory structures and need not checkout ALL the files as was the concern. Reference: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-checkout.html

Step 1: Proceed to repository browser

Step 2: Right click the parent folder within the repository containing all the files that you wish to work on and Select Checkout.

Step 3: Within new popup window, ensure that the checkout directory points to the correct location on your local PC. There will also be a dropdown menu labeled “checkout depth”. Choose “Only this item” or “Immediate children, including folders” depending on your requirement. Second option is recommended as, if you want to work on nested folder, you can directly proceed the next time otherwise you will have to follow this whole procedure again for the nested folder.

Step 4: The parent folder(s) should now be available within your locally chosen folder and is now being monitored with SVN (a hidden folder “.svn” or “_svn” should now be present). Within the repository now, right click the single file that you wish to have checked out alone and select the “Update Item to revision” option. The single file can now be worked on and checked back into the repository.

I hope this helps.

| improve this answer | |

You can do it in two steps:

  1. Checkout an empty SVN repository with meta information only:

    $ cd /tmp
    $ svn co --depth empty http://svn.your.company.ca/training/trunk/sql
  2. Run svn up to update specified file:

    $ svn up http://svn.your.company.ca/training/trunk/sql/showSID.sql
| improve this answer | |

An update in case what you really need can be covered by having the file included in a checkout of another folder.

Since SVN 1.6 you can make file externals, a kind of svn links. It means that you can have another versioned folder that includes a single file. Committing changes to the file in a checkout of this folder is also possible.

It's very simple, checkout the folder you want to include the file, and simply add a property to the folder

svn propedit svn:externals .

with content like this:

file.txt /repos/path/to/file.txt

After you commit this, the file will appear in future checkouts of the folder. Basically it works, but there are some limitations as described in the documentation linked above.

| improve this answer | |

Go to the repo-browser right-click the file and use 'Save As', I'm using TortoiseSVN though.

| improve this answer | |
cd C:\path\dir
svn checkout https://server/path/to/trunk/dir/dir/parent_dir--depth empty
cd C:\path\dir\parent_dir
svn update filename.log

(Edit filename.log)

svn commit -m "this is a comment."

Steve Jessop's answer did not work for me. I read the help files for SVN and if you just have an image you probably don't want to check it in again unless you're doing Photoshop, so export is a better command than checkout as it's unversioned (but that is minor).

And the --depth ARG should not be empty but files to get the files in the immediate directory. So you'll get all the fields, not just the one, but empty returns nothing from the repository.

 svn co --depth files <source> <local dest>


svn export --depth files <source> <local dest>

As for the other answers, cat lets you read the content which is good only for text, not images of all things.

| improve this answer | |
  • 1
    The point of --depth empty was that the other files should not be checked out, and you can then get just a single file with svn up <source/file>. With svn export, there's no need to do this, just specify the file. – Kevin Vermeer Mar 23 '11 at 21:23
  • @reemrevnivek - you are right. well the question just asked for a single file, this does work without the checking out of the whole directory structure file even if it is empty. – Vass Mar 24 '11 at 17:53

I'd just browse it and export the single file. If you have HTTP access, just use the web browser to find the file and grab it.

If you need to get it back in after editing it, that might be slightly more tedious, but I'm sure there might be an svn import function...

| improve this answer | |

Do something like this:

mkdir <your directory>/repos/test

svn cat http://svn.red-bean.com/repos/test/readme.txt > <your directory>/repos/test/readme.txt

Basically the idea is create the directory where you want to grab the file from SVN. Use the svn cat command and redirect the output to the same named file. By default, the cat will dump information on stdio.

| improve this answer | |

If you just want a file without revision information use

svn export <URL>
| improve this answer | |

With Subversion 1.5, it becomes possible to check out (all) the files of a directory without checking out any subdirectories (the various --depth flags). Not quite what you asked for, but a form of "less than all."

| improve this answer | |

Using the sparse check out technique, you CAN check out a particular file that is already checked out or exists...with a simple trick:

After checkout of the top level of your repository using the 'this item only' option, in Windows explorer, you MUST first right-click on the file you need to update; choose Repo Browser in context menu; find that file AGAIN in repository browser, and right-click. You should now see the "update item to revision" in context menu.

I'm not sure whether it is an undocumented feature or simply a bug. It took me an extended after-work hours to finally find this trick. I'm using TortoiseSVN 1.6.2.

| improve this answer | |

I wanted to checkout a single file to a directory, which was not part of a working copy.

Let's get the file at the following URL: http://subversion.repository.server/repository/module/directory/myfile

svn co  http://subversion.repository.server/repository/module/directory/myfile /**directoryb**

So I checked out the given directory containing the target file I wanted to get to a dummy directory, (say etcb for the URL ending with /etc).

Then I emptied the file .svn/entries from all files of the target directory I didn't needed, to leave just the file I wanted. In this .svn/entries file, you have a record for each file with its attributes so leave just the record concerning the file you want to get and save.

Now you need just to copy then ''.svn'' to the directory which will be a new "working copy". Then you just need to:

cp .svn /directory
cd /directory
svn update myfile

Now the directory directory is under version control. Do not forget to remove the directory directoryb which was just a ''temporary working copy''.

| improve this answer | |
  • Isn't this what sparse checkout does? You really shouldn't be hacking on the files in the .svn directory manually. – Lasse V. Karlsen Feb 4 '12 at 21:22
  • Perhaps but it solved the problem properly. I suppose that, it's the way version management should work, also being abble to handle files as extension of directories. Try it and tell me whats wrong with the logic. Iwould suggest the subversion development team to extend the svn utility with this feature, it would solve the problems of all guy who answered this thread. – hendergassler Feb 4 '12 at 21:29

Since none of the other answers worked for me I did it using this hack:

$ cd /yourfolder
svn co https://path-to-folder-which-has-your-files/ --depth files

This will create a new local folder which has only the files from the remote path. Then you can do a symbolic link to the files you want to have here.

| improve this answer | |
  • The OP asked about svn co of one file to avoid an entire directory full of image files. Also, adding a symlink can only add to the complexity, moving from a temp directory could work, but you still have to check out the entire directory of pictures for just one image. @steve-jessop had the right idea – Chris Marotta Sep 26 '17 at 17:38
  • 2
    @ChrisMarotta the OP asked the question 9 years ago. Nobody here is answering the OP. This is a general topic for this kind of problem, and it has nothing to do with the original OP anymore. People are coming here to find a solution for their own problem. And when they read it, some of them will be in my situation where this was the only proper solution. That's why I posted it. – Lacho Tomov Sep 28 '17 at 17:08
  • 1
    I am happy for this answer, it helped me – Leos Literak Feb 19 at 8:24

This issue is covered by:


There is a script attached that lets you check out a single file from svn, make changes, and commit the changes back to the repository, but you can't run "svn up" to checkout the rest of the directory. It's been tested with svn-1.3, 1.4 and 1.6.

| improve this answer | |

If you just want to export the file, and you won't need to update it later, you can do it without having to use SVN commands.

Using TortoiseSVN Repository Browser, select the file, right click, and then select "Copy URL to clipboard". Paste that URL to your browser, and after login you should be prompted with the file download.

This way you can also select desired revision and download an older version of the file.

Note that this is valid if your SVN server has a web interface.

| improve this answer | |
