Search code examples
gitgit-history-rewrite

Concatenate two git repository histories


I want to combine a cvs and a svn repository into a new git repo, without loosing history of course. The catch is the svn repo is a direct continuation of the cvs repo historywise. Someone just created the svn repo and clumsily added the last state from cvs without keeping any history. The most recent sources are in svn. I don't want to keep the old repos.

The history in graphics:

CVS: A - B - C
SVN: D - E - F - G

What I want:

GIT: A - B - C - D - E - F - G

I made a git repo from cvs with cvs2git, and another git repo from svn with git svn clone as outlined in http://john.albin.net/git/convert-subversion-to-git but just can't figure out how to combine the two. I did this:

git clone cvs.git
cd cvs
git remote add svn ../../svn.git
git fetch svn

Now what? git merge -s ours svn/master seems to do what I want but does not create a linear history:

A - B - C - - - H'
               /
D - E - F - G /

Any experiments with git rebase didn't get me anywhere.


Solution

  • Use .git/info/grafts to connect histories and then git filter-branch to make it permanent. There is a some description how somebody done it: http://bugsquash.blogspot.co.uk/2010/03/stitching-git-histories.html