I am trying to migrate an SVN repository that was formerly 2 svn repositories (but within the same svn server, so sharing commit numbers), which was then combined.

So initial state (two repos):


Combined state (1 repo with folders)


The per repo history ends up looking "interesting" but the per file history is preserved in svn (and svn annotate works perfectly).

When attempting to move this to git using git svn git behaves as if these files were first created at the point the 2 repos were combine and loses any history from before then. This is arguably not unreasonable as this is when those files entered the repository, but in git terminology it is perhaps "two forks that forked when no work had been done, remained separate for several years then merged"


Is it possible to migrate an SVN repository that was once 2 SVN repositories to git while maintaining history from before the 2 svn repositories were merged

Related Questions

My problem looks similar to How can I clone an svn repository that changed layouts with git maintaining full history? however my case seems worse, as I have 2 competing repos being combined, rather than just a structure change.

  • Why not just do a git merge <remote> <branch> --allow-unrelated-histories? See: git-scm.com/docs/git-merge#Documentation/… for more info. It's not the cleanest approach, but it does do the trick and might be less risky from the standpoint of losing history. The merge will be ugly, but it will be a traditional merge. – Greg Burghardt Oct 16 at 19:44
  • @Greg is that an addendum to sevensevens suggestion; ie. do it in several parts. Just want to make sure theres not something I can do to take the entire SVN history (which included unrelated history merges) in one shot as part of the git svn clone command – Richard Tingle 22 hours ago
  • Unfortunately there is no magic here. The Git SVN clone is its own history. You can commit to it, and sync it with SVN, but if your intention is to just move to Git, then to the ugly merge once with --allow-unrelated-histories and wade through the conflicts. This should be a one time thing if the files and directory structure are the same. File renames in either version control will be ugly conflicts, but other than that resolving conflicts shouldn't be too bad. – Greg Burghardt 19 hours ago

Is it possible to migrate an SVN repository that was once 2 SVN repositories to git while maintaining history from before the 2 svn repositories were merged

Assuming you still have the 2 svn repositories you can git svn clone them into 2 separate git branches and then merge them in git.

This would completely preserve history as you've always got the original branches. You'll have a 3rd branch with the merge.

git svn clone works by checking out each svn commit in order and then creating a matching git commit. The history should be the same as whatever repo you've cloned between svn and git. If you already foo-barred the merge in svn and don't have the original repo, you might be stuck, but that's svn's fault, not git's.

| improve this answer | |
New contributor
sevensevens is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 2
    Would that mean losing the history since the svn repository merge though? – Richard Tingle Oct 16 at 16:52
  • Interesting, with careful selection of the revision numbers to bring it in this could work as a git svn in 3 parts – Richard Tingle Oct 16 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.