Recently, I've been using Subversion as a versioned backup system for a couple of my "settings" folders (an upcoming blog post has an awesome example of this...stay tuned). In this post, I'm going to show you how to import an existing folder structure into Subversion while keeping it as your working folder as well.
Bad way
If you've ever used TortoiseSVN to add an existing folder structure into Subversion, you may have done it like so:
- Right-click the folder you wish to add to version control
- Choose "Import" from the TortoiseSVN menu
- Choose the repository
- Wait for the data to upload
We now have the folder in our repository. But what about versioning local changes made to this structure? Well, you have to get a working copy from Subversion. Since we already have an existing folder with all of the files, we can't do a Checkout in the same place (which is what we want to do) or TortoiseSVN complains. What can we do? Well, we could delete that folder and Checkout.
However, it's not very efficient to upload the entire directory structure to SVN, just to turn around and download the very same data we already have! Here's the solution:
Good way
- Right-click any folder and choose "Repo-browser" from the TortoiseSVN menu
- In the repository, create a folder of the same name as the root of the folder that you wish to import (in the appropriate repo path where you'd like the folder to live)

- Right-click the root folder that you wish to add to SVN and choose "Checkout" from the TortoiseSVN menu
- Choose the path to the newly created, empty folder in the repository, click OK

- Now that you have a working SVN copy, you can right-click the root folder and choose "Add" from the TortoiseSVN menu. Select all the subfolders and files
- Commit (you could also have chosen Commit instead of Add and then added the files from the Commit dialog)
You now have a local, SVN working copy, imported into Subversion, without having to upload AND then download the same data!