Search code examples
gitsvngit-svn

Merge repo git svn clone with other git repo


For years my team has been using SVN. A few months ago we switched to Git by doing a simple push of an SVN branch, without the history and continued to develop on Git. Today we need to get the SVN history back before it is lost. So I used git svn clone to turn SVN into Git.

So I end up with a SVN project, are equivalent in Git project (proj_with_history) and a Git project having the same initial commit as the last commit of one of the branches (proj_without_history) of the proj_with_history.

The question is, how do you link/merge the proj_with_history with the proj_without_history, knowing that new branches and tags have been created on proj_without_history ?

If possible, we would like to make this migration transparent in the graph of the commits, even if the history is rewritten, as long as conflicts are avoided.

  • proj_with_history : ... - f30ab - 98ca9
  • proj_without_history : 34ac2 - h20a5 - ...
  • 98ca9 and 34ac2 have the same code

Solution

  • Fetch the svn clone into a repo with your git history, graft the root of that git history on to the converted svn commit its content came from (git replace --graft $theroot $theoriginaltip), vet the result locally, then bake in the graft with git filter-branch, the brute-force just-do-it version is git filter-branch -- --all --tag-name-filter cat to completely abandon the old history and replace it with the new tips with the extended history.