Recently I wanted to migrate an existing Subversion (SVN) repository trunk to a new Git repository. Here is a short description how you can do it in four simple steps.
First of all, create a new bare repository:
$ mkdir NewGitRepo $ cd NewGitRepo/ $ git init --bare
Secondly, checkout the old SVN repository using Git and enter the repository folder. For this post I created a sample SVN repository on my local hard drive:
$ git svn clone file:///some/file/path/OldSVNRepo/trunk ./OldSVNRepoGit $ cd OldSVNRepoGit
Thirdly, add your new Git repository as additional remote branch to the checked out SVN repository:
$ git remote add origin /some/file/path/NewGitRepo/
Finally, push SVN contents to new Git bare repository:
$ git push -u origin master Counting objects: 12, done. Delta compression using up to 2 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (12/12), 1016 bytes, done. Total 12 (delta 3), reused 0 (delta 0) Unpacking objects: 100% (12/12), done. To /some/file/path/NewGitRepo/ * [new branch] master -> master Branch master set up to track remote branch master from origin.
As stated in the heading, this is just a simple way. Additional information regarding this topic can be found in the Pro Git book by Scott Chacon: