Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 225
kch Avatar asked Nov 06 '08 13:11

kch


People also ask

What is relocate in SVN?

The first svn relocate syntax allows you to update one or more working copies by what essentially amounts to a find-and-replace within the repository root URLs recorded in those working copies. Subversion will replace the initial substring FROM-PREFIX with the string TO-PREFIX in those URLs.

Which migration is actually recommended for migration from SVN to Git?

When moving to Git from another version control system like Subversion (SVN), we generally recommend that you perform a "tip migration", which migrates just the latest version of the repository contents, without including history.

Is SVN same as Subversion?

SVN stands for Subversion. So, SVN and Subversion are the same. SVN is used to manage and track changes to code and assets across projects.


2 Answers

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.

like image 182
kch Avatar answered Nov 10 '22 18:11

kch


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>

like image 28
H Krishnan Avatar answered Nov 10 '22 18:11

H Krishnan