Changing the location of your working copy with Subversion

svnSubversion is a popular version control system that will allow you to keep track of any changes to any files (normally text files or source code). If you’re a developer and you’re not using a version control system it’s kind of like being dragged behind a Jeep instead of driving it, except you don’t realise that’s what’s happening.

Anyway, when using Subversion you “check out” from the repository your own “working copy” of the code. This is where you then make your changes before either reverting them (throwing them out) or committing them (storing them in the repository as the latest version).

There may be situations where the location of the repository (which is usually specified as a URI) may change, and you would prefer to keep your working directory intact rather than having to check out a fresh copy from the new URI.

This is easy enough to do with the “switch” command, like so:

  1. Start a shell and change into the working directory that you’re using, e.g. cd /home/bob/projects/myproject
  2. Issue the svn switch command, with the –relocate option, followed by the old URI and the new new URI, e.g. svn switch –relocate http://hostname.com/svn/myproject http://newhostname.com/svn/myproject

In my particular case I had checked out a working copy from a subversion repository available on my LAN at my workplace, but then when working remotely I could not update or commit files.  The repository is accessible remotely however via HTTPS.  Even though it’s the same physical repository, the URI that I access it by had changed so my command was:

svn switch --relocate http://ace/svn/myproject https://work/svn/myproject

To find the URI of your current working directory, use the “svn info” command and look for the Repository Root:

bob@bob-laptop:/var/www/myproject$ svn info
Path: .
URL: https://work/svn/myproject
Repository Root: https://work/svn/myproject
Repository UUID: a13b7e41-fee6-4c75-a229-83425febcc85
Revision: 498
Node Kind: directory
Schedule: normal
Last Changed Author: bob
Last Changed Rev: 498
Last Changed Date: 2009-11-30 14:01:35 +1300 (Mon, 30 Nov 2009)

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

WordPress Themes