1

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.

Community
  • 1
  • 1
IQn
  • 133
  • 1
  • 4
  • 11

2 Answers2

2

For a one-time migration git-svn is not the right tool for conversions of repositories or parts 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 plenty 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.

You will be easily able to configure svn2gits rule file to produce the result you want from your current SVN layout, including any complex histories.

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.


Even though git-svn is easier to start with, here are some further reasons why using the KDE svn2git instead of git-svn is superior, besides its flexibility:

  • the history is rebuilt much better and cleaner by svn2git (if the correct one is used), this is especially the case for more complex histories with branches and merges and so on
  • the tags are real tags and not branches in Git
  • with git-svn the tags contain an extra empty commit which also makes them not part of the branches, so a normal fetch will not get them until you give --tags to the command as by default only tags pointing to fetched branches are fetched also. With the proper svn2git tags are where they belong
  • if you changed layout in SVN you can easily configure this with svn2git, with git-svn you will loose history eventually
  • with svn2git you can also split one SVN repository into multiple Git repositories easily
  • or combine multiple SVN repositories in the same SVN root into one Git repository easily
  • the conversion is a gazillion times faster with the correct svn2git than with git-svn

You see, there are many reasons why git-svn is worse and the KDE svn2git is superior. :-)

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • Thanks for your reply. Not the answer i was hoping for, but looking in to svn2git you are probably right. I'll try to make a new code file using svn2git – IQn Apr 27 '17 at 12:36
  • If you want to do it with `git-svn`, you might get what you want by specifying multiple trunk locations, you can specify more than one. But I'd still recommend using KDEs `svn2git`. – Vampire Apr 27 '17 at 12:58
0

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
IQn
  • 133
  • 1
  • 4
  • 11
  • 2
    Without the code or a link to the code, this does not seem like it answers the question (at least not for future readers -- like me). – NichtJens Mar 07 '21 at 17:46