Add svn repo to existing git repo?

After searching last night, I have finally found the answer:

http://i-nz.net/2009/01/15/selective-import-of-svn-branches-into-a-gitgit-svn-repository/

It seems that you have to actually go in and manually edit the .git/config file in order to add an svn branch to an existing git repo. So according to these instructions I would have to add an entry for each branch.


The answers for this question (https://stackoverflow.com/a/840411 and https://stackoverflow.com/a/7592152) no longer work as of Git v1.8.3.2 (https://stackoverflow.com/a/19833311). You can do this instead:

1) Define the new branch in .git/config :

[svn-remote "release-branch"]
   url = svn+ssh://[email protected]/source/branches/mono-2-2/mcs
   fetch = :refs/remotes/git-svn-release-branch

2) Import the SVN branch. SVN_BRANCHED_REVISION is the the revision when the branch happened in SVN.

$ git svn fetch release-branch -r SVN_BRANCHED_REVISION

3) Create branch and hook up a local Git branch to the remote branch:

$ git checkout -b release refs/remotes/git-svn-release-branch

5) Update

$ git svn rebase

You can find the SVN_BRANCHED_REVISION by doing:

$ svn log --stop-on-copy PATH_TO_BRANCH

This is actually what git svn init does -- the other git svn commands simply merge things together, etc. You can git svn init and/or copy the layout of an SVN repo cloned with git svn clone, and you should just be able to pull into a local branch, or fetch, and so on. Have some time with the man page for git svn and you shouldn't have too much trouble piecing something together; if you do, #git on freenode is a good resource. So, this should be possible without too much trouble, but I don't know exactly how to do it all.