3

I have to use svn in a large project. I can checkout the trunk of the project without any problem. It takes between 30min / 1 hour. I do it like this:

    svn checkout https://myrepo.com:port/svn/trunk/

but if I try to use git, it takes forever. I've been doing git svn fetch for like two days after getting errors doing the checkout as I read in some answers to similar questions, but nothing. The command I use is

    git svn clone https://myrepo.com:port/svn/trunk/

The issue (I think) is that git is trying to clone EVERYTHING (all branches) plus other stuff which I don't want. On the directory svn, there is trunk and branches but also other directories which I don't need. I want only the trunk.

Is this the normal behavior?

2 Answers 2

4

git svn clone operates much slower mainly because it clones into a non-bare repository. You can improve the clone speed significantly with a bare repo.

Note: Remember to generate the authors file for the migration.

These extra steps will speed up the process of svn → git migration:

  1. git svn clone https://myrepo.com:port/svn/ --stdlayout <deleteMe.git> with all extra parameters like --ignore-paths and what not.
  2. Then cancel the git svn clone operation in step 1, just for the sake of using the .git/config file later.
  3. git init --bare <useMeBare.git>
  4. Replace <useMeBare.git>/config with <deleteMe.git>.git/config.
  5. Edit <useMeBare.git>/config to change bare = falsebare = true
  6. cd <useMeBare.git>
  7. Now, run git svn fetch and notice the improved speed.
  8. When the fetch is done, you can check the file contents by running git clone <useMeBare.git> <migrated.git>
  9. You can also add a new git remote to <useMeBare.git> and push to it to your local GitLab server project / GitHub.
  10. If you later want to rename the migrated branches / tags, this link may be helpful.

Note: To achieve the best possible git svn clone / fetch speed, copy the svn repository locally and svnserve it then git svn clone from it. But this method requires you to use this parameter --rewrite-root so your cloned git repository maintains the original svn URL in the comment.

Hope this helps.

2

With your command it only clones trunk, as you specified the trunk URL. But it still clones its whole history by getting all revisions one after the other and then making a Git commit out of it. This needs ages, especially if you don't do it on the server where the SVN repository is on the filesystem. This is one of the many reasons I discourage from using git-svn or git-svn based tools for one-time migrations.

You might use the --revision parameter to git svn clone to only import a part of the history, e. g. the last 10 commits.

1
  • git svn init also knows about the --ignore-paths command-line option which might help.
    – kostix
    Commented Feb 15, 2017 at 6:26

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