Pointing a Subversion working copy to a moved repository

When I recently bought a new Mac I ran into a problem with Subversion, which I use for version control. I use local repositories, and after moving to the new Mac they ended up in a new location in the file system.

This made my SVN client (Cornerstone) lose track of the repositories, and the checked out working copies still pointed to their respective repository’s old location. Not good.

Telling Cornerstone where the repositories had been moved to was straightforward, as I just had to edit each repository and enter their new locations. Telling each working copy where its repository had moved to was a bit trickier.

As far as I can tell there is no way of doing this from within Cornerstone, so I had to use svn switch from the command-line Subversion client that comes with Mac OS X.

To make a working copy point to a moved repository, open a Terminal window and cd to the root of the working copy. You can verify that the working copy isn't properly connected to its repository by entering svn up – doing so will result in an error message.

Next, enter the following command (make sure to replace my example paths):

svn switch --relocate file:///old/path/to/repository file:///new/path/to/repository .

To verify that the working copy now points to the repository, you can run svn up again. This time you should not get any errors.

Like so many other things, once you know how to do something it’s easy.

Posted on March 18, 2009 in Coding, Productivity