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:
- Switch the svn-remote
url
setting to the new name. - Run
git svn fetch
. This needs to fetch at least one new revision from svn! - Change the svn-remote
url
setting back to the original URL. - Run
git svn rebase -l
to do a local rebase (with the changes that came in with the last fetch operation). - Change the svn-remote
url
setting back to the new URL. - 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:
-
If
svn-remote.svn.rewriteRoot
does not exist in config file (.git/config
):git config svn-remote.svn.rewriteRoot <currentRepositoryURL>
-
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
. 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
(orfetch
path) in.git/config
to point to the new domain/url/pathRun 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 agit-svn-id
pointing to the old path, which doesn't match the one found in.git/config
. As a workaround, change
svn-remote
url
(orfetch
path) back to the original domain/url/pathNow 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 becausegit svn
won't be confused by the fact that thegit-svn-id
of the new head doesn't match with that found in.git/config
.Finally, change
svn-remote
url
(orfetch
path) back to the new domain/url/pathAt this point
git svn rebase
should work again!
The original information was found here.