0

I'm currently importing an SVN repository into Git. The structure of the SVN repository is a bit messy so I'm having to convert it into three separate Git repositories and then merge them all together.

If these was a simple project with three parts to a single history, then I might just rebase them on top of the other, e.g.:

cd part3
git remote add -f part1 url_to_part1
git remote add -f part2 url_to_part2
git rebase part2/master
git rebase part1/master

However part3 in my example above contains dozens of tags and three branches. If parts 1 and 2 had been cleanly merged into master (well, trunk) within SVN, then I would do something like this to graft the branch into the history correctly. This has the benefit that all of the tags stay in place, unlike with a rebase.

But one of the branches has an orphaned commit that we would now like to merge into the history. Now if I try to fix the history with the graft, the changes from the orphaned commit are lost. In the example below, the merge X to C happened in SVN and so I can create the link with a graft. But I want to merge the orphaned commit O in between C and D, while preserving the tags on commits E, G etc.

A-B-C-[ ]-D-E-F-G-H-...  
 \ /  /
  X--O

Is there a way that I can specify the graph structure using something like the grafts file but then actually execute the implied merges? Or is there a filter-branch command that I should be using here?

jkeirstead
  • 2,881
  • 3
  • 23
  • 26
  • The [note on this question](http://stackoverflow.com/questions/3810348/setting-git-parent-pointer-to-a-different-parent/3811028#3811028) suggests this isn't possible with grafts. Guess I'll have to rebase and then manually move the tags. – jkeirstead Aug 24 '16 at 15:25

1 Answers1

1

git-svn is not the right tool for one-time conversions of repositories. It is a great tool if you want to use Git as frontend for an existing SVN server, but for one-time conversions you should not use git-svn, but svn2git which is much more suited for this use-case.

There are pleny tools called svn2git, the probably best one is the KDE one from https://github.com/svn-all-fast-export/svn2git. I strongly recommend using that svn2git tool. It is the best I know available out there and it is very flexible in what you can do with its rules files.

If you are not 100% about the history of your repository, svneverever from http://blog.hartwork.org/?p=763 is a great tool to investigate the history of an SVN repository when migrating it to Git.

You will be able to write the rules file in a way that you can convert your whole SVN repository in one very performant run to a proper Git repository.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • To clarify, I am using svn2git with three different sets of parameters against one SVN repository and then trying to stitch the results together (because a single svn2git command doesn't fit the non-standard layout of the SVN repo). – jkeirstead Aug 24 '16 at 13:22
  • To clarify, you are **not** using the svn2git utility I recommended, otherwise you wouldn't have to jump hoops like you are trying to do. ;-) – Vampire Aug 24 '16 at 13:35