Search code examples
gitsvnversion-controlbitbucketgit-svn

SVN subfolder to GIT Migration with moved folders


The Case

We have a huge SVN repository, with 80 sub-folders, we are trying to split up to multiple GIT repositories and move BitBucked.

I have used the following to migrate the sub-folder in SVN to GIT: git svn clone "https://localhost:40/svn/repo" --trunk="/Customers/[folder]" --prefix="" --authors-file="authors.txt" "[folder]"

It work fine.

The Problem

The "/Customers/[folder]" contains sub-folder previously moved folders from another sub-folder "/Apps/[folder]" in the SVN repository.

Old structure:

repo
--Apps
----Customer1App1
----Customer1App2
----Customer2App1
--Customers
----Customer1
----Customer2

New structure:

repo
--Customers
----Customer1
------Customer1App1
------Customer1App2
----Customer2
------Customer2App1

The problem is the migrated Apps folders in the new GIT repository does not contain any history before this move, like the SVN does. Is there any way to fix this?

Extra Info

I have seen this Getting complete history of an SVN repo that's been renamed using git-svn but can't find a way to convert it to work with sub-folder from outside the new repositories.


Solution

  • I ended up writing my own conversion app in C# using SharpSVN and SharpGit.

    In essence it does:

    • Finds all moves and renames
    • Finds all revision that involved any of above actions
    • And then for each revision it:
      • Checkout main dir
      • Copy changes into the main dir
      • Add all files to Git repo
      • Commit Git repo
      • Revert copy to be able to make a new one (I still needs to optimize this part, to make it faster)
      • Go to new revision