user1232236
user1232236

Reputation: 217

How to get specified files using SVN?

How to get specified files using SVN? Normally if we want to get some dir, we can create a new dir and right click select SVN check out, but how should I do if I only want to get one file?

Thanks. Alex

Upvotes: 0

Views: 115

Answers (2)

Lazy Badger
Lazy Badger

Reputation: 97280

In case of http-repo latest revision of file you'll get using old good URL for http-resource (can't recall format for previous revisions)

For any type of repo svn cat URL > filename

Upvotes: 0

SmartestVEGA
SmartestVEGA

Reputation: 8889

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 older 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 mods, the rest of it will have finished downloading...

Upvotes: 1

Related Questions