Adding a work-in-progress to SubversionPosted by Dylan Beattie on 18 October 2008 • permalink
I love Subversion, but from time to time I'll stumble across a bit of SVN behaviour that just doesn't feel quite right. Case in point - you've created 10-15 files, set up a folder structure for a new project, made rather more progress than you were expecting to, and now you want to check the whole thing into revision control.
The 'proper' way of adding existing code to a repository is via the svn import command, but that doesn't turn your local folder into a Subversion working copy. Having completed the import, you'll then need to move/rename/delete your work in progress, and then do an svn checkout to download the version of your project that's now under revision control. This can take a while if you're working on big files and your repository is on the far end of a slow connection... and even when that's not applicable, it's still frustrating.
So, here's how you can add a new project to Subversion without having to do the import-checkout shuffle.
- Use the repo-browser to create a new empty folder in the repository - this will form the root folder of your new project, so call this folder /myproject/trunk or whatever you'd normally use.
- Check out the empty folder into the folder containing your work-in-progress project. You'll get this warning - which is fine, because what you're doing is 'wrapping' an empty SVN folder around your existing work.
- You'll check out a single folder, and you'll see that your project now consists of a root folder with the happy green SVN icon, containing a bunch of folders with the question-mark overlay that means "Subversion doesn't know about this folder yet..."
- Now you can do an svn commit in the usual way, and it's trivial to add the 'new' files (i.e. all of them) that should be added to the repository. On the first commit, you'll need to uncheck the bin/obj folders for .NET projects, and then on the subsequent commit, you'll be able to add them to the SVN ignore list (you can only ignore a folder whose parent is already under version control)