Migrating multimodule SVN project into GIT with history

Ok, you are using SVN for keeping you sources and you decided to switch into git?

This is easy if your have plain project structure:

-- trunk
    -- module_1
        -- src
    -- module_2
        -- src

You need just import it from svn using git.

But what if you have trunk, branches and tags dirs for every module:

-- module_1
    -- trunk
        -- src
-- module_2
    -- trunk
        -- src

And you don’t want to lose your history.

There are few steps to achieve correct result:

At first, checkout all your trunks into new dir using git svn clone

git svn clone "https://svn-to-git.googlecode.com/svn/trunk/module_1"  module_1 -T trunk
git svn clone "https://svn-to-git.googlecode.com/svn/trunk/module_2"  module_2 -T trunk

Then go to each folder and move src dir into module_name -> src

cd module_1
mkdir module_1
git mv src module_1
git commit -m "Preparing for migrate module 1"

Create new git repository in the same folder and merge other modules inside

git remote add module_1 ../module_1
git fetch module_1
git merge module_1/master
git remote remove module_1

At the end, just add new origin and push it there

git remote add --track origin https://your.git.repo/repo
git push origin master

That’s it. Now you will have proper history from svn and git-like module structure.

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax