1

I am migrating some SVN repos to Bitbucket using git svn clone. It seems that the clone fails when the revision that it is going to clone doesn't exist because the branch it affected doesn't exist anymore in Subversion.

I did

git svn clone -authors-file=authors.txt https://my.svn.com/project001 project001

The logs shows

{...}    
    r12 = f16b3d1014109ccd1c7e24dd70bfa9df45362e48 (refs/remotes/git-svn)
            M       trunk/xx.java
            M       trunk/xx.java
    r13 = 9e61cda58fb2f5afa0a97277a10fd92365f3d1e3 (refs/remotes/git-svn)
            M       trunk/xx.java
            M       trunk/xx.java
    r14 = f9964ce0a8081cf0bf22ee8a5ba32afe725323c3 (refs/remotes/git-svn)
            M       trunk/xx.java
    r15 = ac1f5c4a61346601dd85fbca55bd585ce5fc358d (refs/remotes/git-svn)
    fatal: .git\svn\refs\remotes\origin\https;C:\Program Files\Git\index: index file open failed: Invalid argument
            (in cleanup) update-index -z --index-info: command returned error: 128
    W: +empty_dir: branches/https:/my.svn.com/project001/branches

Exploring the SVN repo it seems that the revision #16 refers to the creation of a branch (wrongly named https:/my.svn.com/project001/branches) that doesn't exist anymore (it was deleted it revision #18).

I guess the problem is caused by this but after reading the docs and browsing SO I dind't find a way to make the git svn clone ignore this. I am looking for an automated way if possible because I have to write a script to migrate several GBs of SVN repos.

2
  • Is this about one-time migration and then only Git is used, or do you want to commit back to the SVN repo from your Git clone? Commented Apr 18, 2017 at 12:23
  • @Vampire It's a one time migration. Commented Apr 18, 2017 at 14:07

1 Answer 1

2

For a one-time migration git-svn is not the right tool for conversions of repositories or repository parts. It is a great tool if you want to use Git as a 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.

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. :-)

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I have tried to use svn2git (not kde's one but nirvdrum/svn2git because I am on Windows) but looks like I am stuck in a recurrent "problem" Running command: git checkout -f master error: pathspec 'master' did not match any file(s) known to git.
nirvdrum svn2git uses git-svn under the hood, so suffers from most of the same drawbacks, just fixing some of them after the actual git-svn cloning. I also use the KDE svn2git on Windows, no problem here.
Thanks! I am going to try KDE svn2git.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.