views:

3479

answers:

4

Treating my repository as a SVN repo, I get:

svn co http://myrepo/foo/trunk foo
...
foo/
  bar/
  baz/ -> http://myrepo/baz/trunk

Treating it as a Git repo, I get:

git svn clone http://myrepo/foo --trunk=trunk --branches=branches --tags=tags
...
foo/
  bar/

I can clone baz to my local machine elsewhere and add a symlink, but that's just a hack. Is there a way to have git svn rebase automatically pull in those changes when it updates everything else, just like svn up does?

+6  A: 

The best means of integrating svn externals with git-svn that I've seen is this script, which clones your externals into a .git_externals/ directory and creates the symlinks and exclude files you need. I find this a simple and direct solution. YMMV.

Here is an older overview of other options for dealing with svn externals with git-svn. To me they look a little over-complicated and liable to break under subsequent Git use.

Paul
+3  A: 

The solution I ended up using was just to symlink to other git-svn clones on my local box. This worked pretty well: it allows me to commit changes back, and it allows me to make local changes on project A just to get them into project B.

James A. Rosen
A: 

I decided to write a "simple" perl script to handle all this stuff for me. I've put it recently to github, try it out, maybe it would help: http://github.com/sushdm/git_svn_externals/.

It essentially does git-svn clone for all externals found, and it looks for them recursively, clones, symlinks them in proper places and excludes all .git_externals dirs and symlinks so that you can still use 'git svn dcommit'.

Good luck.

Dmitry
A: 

I also made a script (both Perl and Ruby variants available) that does this for me, it's at http://github.com/liyanage/git-tools/.

  • Recursively checks out all svn:externals
  • Can be run repeatedly in case the clone of a large repository aborts halfway through. Happened to me a lot. It picks up where it left off.
  • Adds all svn:externals entries it finds and processes to .git/info/exclude
  • Adds all svn:ignore entries it encounters to .git/info/exclude
  • Can be run regularly after the first run to do the svn:rebase in all cloned sub-sandboxes, discover new externals and new svn:ignores
Marc Liyanage
@Marc - I sadly couldn't get your tools to work.
sheepsimulator
I'd like to learn what didn't work for you so I can improve the script. Can you contact me?
Marc Liyanage