I’m looking for a way to permanently (i.e. no git-svn will be used after the import and the repo will be cloned again to get rid of all git-svn remainders) migrate one of my SVN repositories to git. Usually this would be an easy thing – just doing the steps explained at http://www.jonmaddox.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/.
However, in the SVN repository I switched to the trunk/branches/tags structure after some time, so about half of the ~2000 commits are working with the actual trunk being in / while the other half have it in /trunk/ (i.e. there’s one big commit moving everything) so neither using -s nor not using it when performing the git svn initialization will work properly.
I’m now looking for a way to import the repository to git properly, i.e. preserving the branch information (no tags, I never created any) while not messing up old commits. In case that’s not possible I’d like to know if there’s a way to rewrite the old commits to change the repo so it uses the trunk/branches/tags structure – then I could simply use -s in git-svn.
TL,DR: It is possible to fix a messy up repository like the one described in the question when some manual work is acceptable. The easiest way is doing it with the SVN dump file and then simply importing it using git-svn with the stdlayout option.
I managed to do it by rewriting the svndump of the repository to include the proper structure from the beginning:
Then I used a small inline Perl script to change the folders:
Since the dump was now invalid – the
trunkfolder needed to be created in r0 and the commit moving everything from/to/trunkneeded to be obliterated – I edited the dump file manually (luckily all metadata are plaintext) and added the following at the beginning of the changes for r0:In the commit moving all the files I removed all actions and added the following to create the
branchesfolder (likewise for thetagsfolder if I had used it)The edited dumpfile could now be loaded using
svnadmin load, giving me a repository that could be imported by git-svn without any issues.