threads / discuss / 23137

Migrating from SVN

Subject: Migrating from SVN

## tl;dr

3 messages between Mar 22, 2010 and Mar 26, 2010.

replies: 2people: 2as markdown or json

Christoph Bartoschek· Mar 22, 2010, 10:18 UTC · lore
Hi,

we consider migrating from Subversion to Git. However we are not sure how to cleanly migrate the history from Subversion to Git. Till now we have such a structure in a single Subversion repository:

project_A project_B project_C project_D project_E

Via svn:externals we form two products:
product_1/project_A
          project_B
          project_C
product_2/project_B
          project_C
          project_D
          project_E
Now we are merging both products into one such that the structure should be 
product/project_A
        project_B
        project_C
        project_D
        project_E

I think this makes migration to Git easier as we can now work with only one Git repository. We also circumvent the usage of the unmature submodule support in Git.

How can I now import our Subversion projects into the Git repository such that for each project the history is kept and ideally the whole history is linearized by the subversion revision numbers?

Thanks Christoph

Heiko Voigt· Mar 25, 2010, 06:22 UTC · re: Christoph Bartoschek · lore

Re: Migrating from SVN

On Mon, Mar 22, 2010 at 11:18:18AM +0100, Christoph Bartoschek wrote:
Show 15 quoted lines
> Now we are merging both products into one such that the structure should be 
> 
> product/project_A
>         project_B
>         project_C
>         project_D
>         project_E
> 
> I think this makes migration to Git easier as we can now work with only one 
> Git repository. We also circumvent the usage of the unmature submodule 
> support in Git.
> 
> How can I now import our Subversion projects into the Git repository such 
> that for each project the history is kept and ideally the whole history is 
> linearized by the subversion revision numbers?

Import them all seperately into git (e.g. using git svn) and then have a look at subtree merge

http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html

to merge them all together. That way you will have seperate lines of history for each project and one (or five) big merges on top.

AFAIK the revision number from svn is stored in the commit message if you use git svn so to add the project name you might want to use git filter-branch to add that name to each commit before merging the history lines.

That way you will have all the history of the now seperate projects in one git repository. Keep in mind that after doing that its not that easy to make them seperate projects again.

Hope that helps.
cheers Heiko
Christoph Bartoschek· Mar 26, 2010, 11:15 UTC · re: Heiko Voigt · lore

Re: Migrating from SVN

Heiko Voigt wrote:
> Import them all seperately into git (e.g. using git svn) and then have a
> look at subtree merge
> 
> http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-
subtree.html
Show 12 quoted lines
> 
> to merge them all together. That way you will have seperate lines of
> history for each project and one (or five) big merges on top.
> 
> AFAIK the revision number from svn is stored in the commit message if
> you use git svn so to add the project name you might want to use git
> filter-branch to add that name to each commit before merging the history
> lines.
> 
> That way you will have all the history of the now seperate projects in
> one git repository. Keep in mind that after doing that its not that easy
> to make them seperate projects again.

Thanks for your suggestion. Unfortunately I do not want to have separate lines of history.

For example if the subversion revisions are like this:

rev 0: Initial import rev 1: Change in project_A rev 2: Change in project_B rev 3: Change in project_A rev 4: Change in project_C

Then I would like to have in git for the product_1 line:
First commit: The commit consists of the initial import.

Second commit: The commit consists of rev 1 of project_A and rev 0 of project_B and rev 0 of project_C.

Third commit: The commit consists of rev 1 of project_A and rev 2 of project_B and rev 0 of project_C

Fourth commit: The commit consists of rev 3 of project_A and rev 2 of project_B and rev 0 of project_C.

Fifth commit: The commit consists of rev 3 of project_A and rev 2 of project_B and rev 4 of project_C.

This does not yet include branches. But how can I get a history like that in git?

A similar line of history would appear for product_2 and when they are merged, I can use a subtree merge as sugested to combine them.

Christoph

← back to recent threads