How to git svn clone full history despite svn copy

2.3k Views Asked by At

In my company we are about to switch from svn to git. The SVN we use is very big, doesn't have a svn layout and on every version split we made a svn copy.

SVN Repository structur:

  • svnserver.company.de
    • product xy
      • majorversionnumber 1
      • majorversionnumber 2
      • majorversionnumber 3
        • minorversionnumber 3.0.0
        • minorversionnumber 3.0.1
        • minorversionnumber ...
      • majorversionnumber 4
      • ....
    • product zw

What we want or what i was expecting git to do:

git svn clone does clone all files from one subfolder / copy with the full history of these files (like tortoise does by unchecking "Stop on copy/rename").

What git is doing:

git svn clone --prefix=origin/ --username=spe --authors-file=authors.txt https://svnserver.company.de/repos/product/majorversionnumber/Master/Source product

-> does clone all files from one subfolder / copy but only with the history until the copy has taken place.

The Question:

Has git a equivalent to svns "Stop on copy/rename" or how to clone full history despite svn copy?

What i have found so far: Git-svn - import full history Work-around for failing "git svn clone" (requiring full history) https://github.com/githubtraining/zzz_deprecated-feedback/issues/43

To be honest, i didn't understand the solution approaches of these links neighter if they had the same problem as we do.

1

There are 1 best solutions below

0
Matt McHenry On

Okay, so if I understand correctly your full layout is like this:

svnserver.company.de
  product xy
    majorversionnumber 1
      master
        <actual source starts here>
    majorversionnumber 2
    majorversionnumber 3
      master
        <actual source starts here>
      minorversionnumber 3.0.0
        master
          <actual source starts here>
      minorversionnumber 3.0.1
      minorversionnumber ...
    majorversionnumber 4
    ....
  product zw

This is just an untested educated guess, but I'd try something like this. First, git svn init svn://svnserver.company.de. Then edit .git/config's [svn-remote] section to look something like this:

fetch = product xy/majorversionnumber 1/master:refs/remotes/origin/trunk
branches = product xy/{majorversionnumber 2,majorversionnumber 3}/master:refs/remotes/origin/branches/*
branches = product xy/majorversionnumber 3/{minorversionnumber 3.0.0,minorverionnumber 3.0.1}/master:refs/remotes/origin/branches/*

Then git svn fetch. You can use similar commands + config to create a clone for product zw.

See the CONFIGURATION section of git help svn for more details.