gitgit-svn

How can I convert SVN to Git while splitting one huge repository into separate repositories?


I'd like to migrate our SVN repository to git.

Our current repository is a huge singleton pile comprising a number of Visual Studio solutions, all residing in separate sub directories of the repository.

When transforming it to git I'd like to split the SVN repository into separate git repositories for each solution while maintaining each solution's history at the same time.

I don't want the history of the whole SVN repository in all of our future git repositories. All I want in these future git repositories is the history of a particular sub directory.

Is this possible?


Current SVN repository file structure:

svn_base
   |-- Solution1
   |   |-- 1.cs
   |   |-- 1.csproj
   |   |-- 1.sln
   |-- Solution1
   |   |-- 2.cs
   |   |-- 2.csproj
   |   |-- 2.sln
   |-- Solution3
   |   |-- 3.cs
   |   |-- 3.csproj
   |   |-- 3.sln

Desired git respository file structure:

Solution1
   |-- .git
   |-- 1.cs
   |-- 1.csproj
   |-- 1.sln

Solution2
   |-- .git
   |-- 2.cs
   |-- 2.csproj
   |-- 2.sln


Solution3
   |-- .git
   |-- 3.cs
   |-- 3.csproj
   |-- 3.sln

Solution

  • If your projects are neatly separated into their own subdirectories this should be quite straight forward using the --trunk parameter to git svn init/git svn clone:

    git svn clone --trunk=Solution1 $SVN_URI ./Solution1
    

    This will clone the only the history of the subfolder Solution1 into a new git repository in the directory ./Solution1. It will only include commits that touch files in that subfolder and it will adjust the relative path so that the subfolder is the root directory of the new git repository.