How to clone a nonstandard svn repo to git?

I try to clone a svn repo to git, but some of the branches are in the svn root dir like follows.

I’ve tried

  • Receiving error when try to clone a repository - git
  • How can I avoid an accidental dcommit from a local branch
  • Need help loading a git-completion.bash file
  • Git reset --hard, still got unwanted stuff from my pull
  • Already uptodate in git - GIT PULL works but not GIT FETCH
  • Importing Alamofire 3.4 - No such module 'Alamofire'
  • $ git clone svn://url/svn-root -T trunk -b branches -b branch1 -b branch2
    

    and

    $ git clone svn://url/svn-root -T trunk -b branches -b .
    

    Both are failed to clone the branch1 and branch2 correctly. Please help.

    svn-root
    ├── branch1
    ├── branch2
    ├── branches
    │   ├── branch3
    │   └── branch4
    └── trunk
    

  • Unexpected merge conflict with git
  • Problem with git
  • How can I link branches with issues in BitBucket?
  • How to pull a single file from a server repository in Git?
  • Do not commit specific changes to the git, but also don't revert them from my local workspace
  • how to find size of android repository
  • 2 Solutions collect form web for “How to clone a nonstandard svn repo to git?”

    One interesting tool, mentioned in GitMinutes Episode 20, is SubGit, a plugin for Atalssian Stash (which isn’t free, but you can try it for free).
    You can know much more about SubGit in “GitMinutes #22: Alexander Kitaev about SubGit”.

    It is designed to managed unconventional svn repo layout.

    http://subgit.com/img/stash/105_repository_layout.png

    Dmitry Pavlenko comments:

    you should enter in the “Branches” field:

    *:refs/heads/*;branches/*:refs/heads/branches/* 
    # instead of 
    branches/* 
    

    In this case branch1 will be translated to refs/heads/branch1,
    branch3 — to refs/heads/branches/branch3.

    Alternatively, if you have limited number of top-level branches, you can enumerate them explicitly:

    branch1:refs/heads/branch1;
    branch2:refs/heads/branch2;
    branches/*:refs/heads/bra‌​nches/*
    

    Two options come to mind:

    • Clean up your SVN repo first (Move branches below /branches, where they should be according to standard layout).
    • Checkout using standard layout, add remote branch refs later on.
    Git Baby is a git and github fan, let's start git clone.