Add svn repo to existing git repo? Add svn repo to existing git repo? git git

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://xxxx@mono-cvs.ximian.com/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