# Importing merges when converting repos from SVN to Git (fusing grafts in the Git history)

3 messages from 2008-01-08 to 2008-01-21. Participants: Benoit Sigoure, Johannes Sixt.
Thread: https://gitlist.dev/t/11531

## Benoit Sigoure, 2008-01-08 14:48

Subject: Importing merges when converting repos from SVN to Git (fusing grafts in the Git history)
Message-ID: <744EF0AD-4773-4A35-B772-94621E9ADA10@lrde.epita.fr>
URL: https://gitlist.dev/e/744EF0AD-4773-4A35-B772-94621E9ADA10%40lrde.epita.fr

```
Hi list,
I'm in the processing of converting the SVN repos of my company to  
Git.  We have been using scripts to handle the merge hell with SVN  
and these scripts always mentioned what was merged where in the  
commit message.  The first line is typically: merge -r FROM:TO  
https://svn.fake-company.com/svn/project/{trunk,branches/branch-name}
I'm going to import the repositories with `git-svn' and then I'd like  
to rewrite the entire history to take these merges in account in the  
Git repo, if possible.  This will probably help us merging the  
(former) SVN branches in our new Git repo.  I know I can simulate a  
merge with a graft and I think it will be fairly easy to write a  
small script that parses the log and generates the corresponding  
graft file.  Now the question is: how to make these grafts part of  
the *real* history so that we don't have to depend on the graft file  
anymore?

I know this issue has already been raised on the ML (the "how to  
include grafts are real merges in the history" thing) but I couldn't  
find the corresponding posts and can't remember the conclusion...

Thanks!

-- 
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory

```

## Johannes Sixt, 2008-01-08 15:13

Subject: Re: Importing merges when converting repos from SVN to Git (fusing grafts in the Git history)
Message-ID: <47839311.2010606@viscovery.net>
URL: https://gitlist.dev/e/47839311.2010606%40viscovery.net
In-Reply-To: <744EF0AD-4773-4A35-B772-94621E9ADA10@lrde.epita.fr>

```
Benoit Sigoure schrieb:
> I'm going to import the repositories with `git-svn' and then I'd like to
> rewrite the entire history to take these merges in account in the Git
> repo, if possible.  This will probably help us merging the (former) SVN
> branches in our new Git repo.  I know I can simulate a merge with a
> graft and I think it will be fairly easy to write a small script that
> parses the log and generates the corresponding graft file.  Now the
> question is: how to make these grafts part of the *real* history so that
> we don't have to depend on the graft file anymore?
> 
> I know this issue has already been raised on the ML (the "how to include
> grafts are real merges in the history" thing) but I couldn't find the
> corresponding posts and can't remember the conclusion...

	git-filter-branch --tag-name-filter=cat --all

should do it. It rewrites nothing but the parenthood, so you will find
that the rewritten history shares everything with the original history up
to the first merge(s).

You better run this on a "cp -al" copy of the original converted
repository because it *overwrites* the tags.

-- Hannes

```

## Benoit Sigoure, 2008-01-21 18:36

Subject: Re: Importing merges when converting repos from SVN to Git
Message-ID: <A35436D5-71EA-4185-BBC1-4ECCE4D63A0E@lrde.epita.fr>
URL: https://gitlist.dev/e/A35436D5-71EA-4185-BBC1-4ECCE4D63A0E%40lrde.epita.fr
In-Reply-To: <47839311.2010606@viscovery.net>

```
Hi people,
I wrote a script (svn-merge2git [1]) that helps to convert SVN merges  
to Git merges.  The script basically detects the merges from their  
commit message and re-create them properly on the Git side.  It took  
me several iterations to get it right but it eventually successfully  
converted a SVN repo with ~2500 revisions in a dozen of branches with  
~100 merges in between them.  The script can be used when one wants  
to entirely convert a SVN repo to a Git one while preserving the  
merges (that is, showing the merges in the Git history).  I guess it  
can also be used to inject merges in the history of a git-svn repo to  
facilitate merging of SVN branches with Git, although I haven't had  
time to experiment this for now.

I hope this will be helpful to others.

[1] Code and explanations at: http://repo.or.cz/w/svn-merge2git.git

-- 
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory

```
