Cloning a Non-Standard Svn Repository with Git-Svn

Solution 1:

Lee B was right. The answer, provided by doener in #git, is to upgrade Git to 1.6.x (I had been using 1.5.x). 1.6.x offers deep cloning so that multiple wildcards can be used with the --branches option:

$ git svn clone https://svn.myrepos.com/myproject web-self-serve \ 
          --trunk=trunk --branches=branches/*/* --prefix=svn/
$ git branch -r
  svn/development/sandbox1
  svn/development/feature1
  svn/development/sandbox2
  svn/development/sandbox3
  svn/development/model-associations
  svn/maintenance/version1.0.0
  svn/trunk

Exactly what I needed. Thanks for the insight, all.

Solution 2:

Could you try nirvdrum's svn2git (seems the most up-to-date) in order to import your svn into a git repository ?
(Early 2009, Paul mentioned this iteman's svn2git in replacement of this original jcoglan's svn2git, which was, as his author mentioned: "a quick hack to get my code out of Subversion")

It is better than git svn clone because if you have this code in svn:

  trunk
    ...
  branches
    1.x
    2.x
  tags
    1.0.0
    1.0.1
    1.0.2
    1.1.0
    2.0.0

git-svn will go through the commit history to build a new git repo.
It will import all branches and tags as remote svn branches, whereas what you really want is git-native local branches and git tag objects.
So after importing this project, you would get:

  $ git branch
  * master
  $ git branch -a
  * master
    1.x
    2.x
    tags/1.0.0
    tags/1.0.1
    tags/1.0.2
    tags/1.1.0
    tags/2.0.0
    trunk
  $ git tag -l
  [ empty ]

After svn2git is done with your project, you'll get this instead:

  $ git branch
  * master
    1.x
    2.x
  $ git tag -l
    1.0.0
    1.0.1
    1.0.2
    1.1.0
    2.0.0

Of course, this solution is not meant as a one-way trip.

You can always go back to your svn repository, with... git2svn (also present there)

The idea remain:

  • SVN at work as a central repository.

  • Git "elsewhere" to quickly experiment amongst multiple Git-private branches.

  • import back only consolidated Git branches into official SVN branches.

Solution 3:

For repo layouts not served by plain wildcards: (from my answer to this related question)

The current git-svn manpage says:

It is also possible to fetch a subset of branches or tags by using a comma-separated list of names within braces. For example:

[svn-remote "huge-project"]
     url = http://server.org/svn
     fetch = trunk/src:refs/remotes/trunk
     branches = branches/{red,green}/src:refs/remotes/branches/*
     tags = tags/{1.0,2.0}/src:refs/remotes/tags/*