SVN: Relocating repository URLs with svn switch –relocate

You are using subversion (svn) for version control for a web-based software project you are doing. Your svn server is hosted on your laptop behind a DSL with a dynamically allocated IP address. You checkout the head revision on a live server one day, make changes in a few files on the server, and try to commit the changes back to the svn server the next day. Hell ensues. You’re doomed.

Not quite. If you have heavily used svn for version control for your projects, chances are good you might have come across such a problem. No? Well, at least, I did. Since my svn repository is on a system that gets assigned a dynamic IP address every time I power up the DSL and since power outages are all too frequent where I live and since I don’t have a backup solution such as UPS save for a generator, I often run into the sort of svn trouble I described above.

The fix? Three words: svn switch –relocate (jump to the last example).

TortoiseSVN has a similar “relocate” button that does the same thing. I wasn’t familiar with the actual svn command it uses behind the scenes until Tili enlightened me.


10 thoughts on “SVN: Relocating repository URLs with svn switch –relocate

  1. I don’t run (nor intend to run) any version control system on a Windows box (as long as I am sane).

    No, I have not heard of `svk’ nor `darcs’. I will look at them tomorrow morning. As far as git is concerned, I have read about it. I have been meaning to take it on a test drive. I guess I will some day pretty soon.

    Thanks for the comments.

  2. And, god, no, I think running a version control server on Windows is a horrendously ludicrous thought, if not idea.

    As stupid as that may sound, I know personally of software houses that host their version control systems on Windows (and I don’t mean that bastard of a version control thingy called Visual Source Safe). If that didn’t surprise you, I know of software houses that have custom made VCS that they call “custom CVS repository”. Cracks me up!

  3. Hey, I just ran into this problem and noticed google found a helpful post not only from this decade, but from the past week!

    I want to clarify what you are doing before I end up destroying my project.

    I had an SVN repository on at URL ‘A’.

    The hosting service changed it to ‘B’.

    I have a working copy checked out with a lot of changes to commit, and I want to commit it to ‘B’, but the svn metadata on my checkout is pointing to ‘A’, so obviously ‘svn commit’ won’t work.

    Just to clarify what you said:

    PROMPT> svn switch –relocate A B

    will change my current working copy’s server to B (without updating or modifying any of the files) and

    PROMPT> svn commit

    will then commit my working copy’s changes to B just as it would have if A still worked.

    Is that correct?


  4. That’s correct, Joe. You’ve got that right!

    When you checkout from a repository, files inside the .svn folders in your copy of the repository contain URLs that point back to the repository. What svn switch –relocate essentially does, and I may be wrong on this, is go into each of those .svn folders, and run a s/old_url/new_url/ across all the files so that subsequent svn commands on your copy will see new_url as the actual repository.

  5. Hello :)

    I came across to the same problem, for a different reason though. I just wanted to relocate the path to my SVN repo not the server.

    To avoid your problems with server relocation you could use some dynamic dns service. Something like I use them for my host, and I don’t mess with IPs anymore.

    Have a nice day :)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s