git-svn with multiple svn repositories

At a customer they are switching the control of the svn server to another department. To make sure the new server works like it should, we’re running a trail period.

The project I’m working on was chosen as the trail project. This means I have to┬ásynchronize both repositories. Luckily I’m using git-svn instead of pure svn. (IMHO the new server should have been git! Not oldschool svn).

Thanks to git I’m able to commit to both repositories from the same physical project on my disk. This wouldn’t be possible with only svn. It would be hell.

How did I set it up?

Initially I cloned the repo with git svn clone. So my master branch is connected with one svn repo allowing me to push commits to it with git svn dcommit.
To connect the second svn repo I added a second ref in git config file.

In your .git/config file you should have something like:

[svn-remote "svn"]
url = http://my.repo.example.org/trunk
fetch = :refs/remotes/git-svn
[svn-remote "othersvn"]
url = https://my.newrepo.example.org/trunk
fetch = :refs/remotes/visualsvn

Pull everything from the second ref.

git svn fetch --all

Then create a new local branch (e.g. master-svn2) from that ref.

git checkout othersvn -b localothersvn

That branch will be connected to the second svn.

Now start merging from master to master-svn2 and git svn dcommit in both local branches.
In my case I could just do git merge master --strategy recursive --strategy-option=theirs in master-svn2 squashing most of my commits into 1 since no one is working on the second svn repo and I’m just syncing it.

I did notice that you can’t rebase from one local branch to another because the remote ref is also rebased and you end up with your 2 local branches pointing to the same svn.

Using this you could commit the same code to an endless amount of svn repositories. Don’t really known why you’d do that, but it’s possible.

I did encounter one issue at a certain time. error: git-svn died of signal 6 after googling it I ended up on Joachims blog. The background of the issue is a little different for Joachim but git svn rebase on master-svn2 did the trick.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.