Tuesday, May 11, 2010

How to checkout single file from SVN

I've been using SVN for a long time and I was in the habit of checking out the whole folder even if I needed a single file. This habit of mine was working well until I had to check out the folder with around 200 files with hundreds of megabytes of data. I then realized what I've been missing. I tried to checkout single file but SVN wouldn't let me do that. From my perspective, it should be simple as checking out the folder, but it was not. There could be some reasonable explanation for this limitation but I needed to checkout the file and quickly finish my job. After spending few mins on the Internet, I found the solution and thought it would be wise to share it. So, here it goes.
  1. Right click on the folder in which you would like to check out the file and select 'SVN Checkout...' from the menu.
  2. In the Checkout screen, in URL of repository text box, fill the URL to the folder in the repository from which you would like to checkout the file.
  3. Select 'Only this item' from the drop down menu from 'Checkout Depth' in the same screen. Click 'OK' button.
  4. You can now see SVN overlay icon on the folder. Also, you will notice that the folder is still empty. Let's check out the single file now.
  5. Now, right click again on the same folder and select 'TortoiseSVN -> Repo-browser' from the menu.
  6. Repository Browser will take you directly to the folder from which you would like to checkout the file and you can see the files on the right hand side of the screen.
  7. Right click on the desire file and select 'Update item to revision' from the menu. Click 'OK' on the next screen. Voila, you have successfully checked out single file.
  8. If you have some more files (but not all) to checkout, repeat the last step.
Although it takes little time to check out a single or few files from the repository, I think it's worth doing this way rather than checking out the whole folder when the folder it huge in size. What do you think?


abhijeet said...

brilliant....solved a big problem for me....thanks a ton..

Sameer Navare said...

Gr8 solution.
I was looking for this since a long time

nasir said...

thanks for posting this solution.

Anonymous said...

Hi Milan,

Great jobs. well narrated

Thanks :)

Anonymous said...

Thanks for the solution.