git-svn: what's the equivalent to `svn switch --relocate`?

An svn repository I'm mirroring through git-svn has changed URL.

In vanilla svn you'd just do svn switch --relocate old_url_base new_url_base.

How can I do this using git-svn?

Simply changing the svn url in the config file fails.


Solution 1:

This handles my situation pretty well:

https://git.wiki.kernel.org/index.php/GitSvnSwitch

I cloned using the file:// protocol, and wanted to switch to the http:// protocol.

It is tempting to edit the url setting in the [svn-remote "svn"] section of .git/config, but on its own this does not work. In general you need to follow the following procedure:

  1. Switch the svn-remote url setting to the new name.
  2. Run git svn fetch. This needs to fetch at least one new revision from svn!
  3. Change the svn-remote url setting back to the original URL.
  4. Run git svn rebase -l to do a local rebase (with the changes that came in with the last fetch operation).
  5. Change the svn-remote url setting back to the new URL.
  6. Now, git svn rebase should work again.

Adventurous souls may want to try --rewrite-root.

Solution 2:

You can see if the following works OK:

  1. If svn-remote.svn.rewriteRoot does not exist in config file (.git/config):

    git config svn-remote.svn.rewriteRoot <currentRepositoryURL>
    
  2. If svn-remote.svn.rewriteUUID does not exist in config file:

    git config svn-remote.svn.rewriteUUID <currentRepositoryUUID>
    

    The currentRepositoryUUID can be obtained from .git/svn/.metadata.

  3. git config svn-remote.svn.url <newRepositoryURL>

Solution 3:

Unfortunately most of the links in these answers aren't working, so I'm going to duplicate a bit of information from the git wiki for future reference.

This solution worked for me:

  • Edit the svn-remote url (or fetch path) in .git/config to point to the new domain/url/path

  • Run git git svn fetch. This needs to fetch at least one new revision from svn!

  • If you attempt git svn rebase now, you'll get an error message like this:

    Unable to determine upstream SVN information from working tree history
    

    I think this is because git svn is confused by the fact that your latest commit prior to the fetch will have a git-svn-id pointing to the old path, which doesn't match the one found in .git/config.

  • As a workaround, change svn-remote url (or fetch path) back to the original domain/url/path

  • Now run git svn rebase -l again to do a local rebase with the changes that came in with the last fetch operation. This time it will work, apparently because git svn won't be confused by the fact that the git-svn-id of the new head doesn't match with that found in .git/config.

  • Finally, change svn-remote url (or fetch path) back to the new domain/url/path

  • At this point git svn rebase should work again!

The original information was found here.