I want to use git to clone a svn repository, but unfortunately, where svn checkout
gets the repo with all externals, git svn clone
only gets the repository without externals. How can I get the externals from the svn repository via git svn
? I don't want to do any fancy stuff, just get the the complet repo with externals.

- 10,835
- 3
- 47
- 61

- 5,082
- 15
- 55
- 86
-
there is https://github.com/andrep/git-svn-clone-externals – unhammer Jan 31 '17 at 09:17
3 Answers
git-svn doesn't support externals, but you may try SmartGit instead of git-svn. It supports svn:externals, converting them into .gitsvnextmodules file and displaying as modules. The only restriction: you should clone the repository with SmartGit instead of opening already existing git-svn repository.

- 8,530
- 3
- 30
- 38
-
The followup question: [Does SmartGit support git-svn?](http://stackoverflow.com/q/16128118/86967) – Brent Bradburn Jul 29 '15 at 22:01
-
1Partially. It has compatibility and incompatibility modes. In the first one it fully emulates git-svn (hence doesn't support externals) in the second one it supports externals but not git-svn (i.e. git-svn commands will fail, you'll have to use UI to work with the repository). So you should choose. – Dmitry Pavlenko Jul 30 '15 at 06:08
-
SmartGit only creates a .gitsvnextmodules and after calling "git submodule update --init --recursive" nothing happens. So I assume there is something not working correct... – user1911091 Mar 27 '20 at 14:32
-
It is written in the doc (http://wvvw.syntevo.com/doc/display/SG/SVN+Integration) that "Only externals pointing to directories are supported, not externals pointing to individual files ('file externals')." – user1911091 Mar 27 '20 at 17:52
I have been use git as a front end to access a SVN repository. The structure in SVN is generally pretty simple such that there is top level directory which has the externals in it and no externals in sub-directories. Also the externals don't really change much once they are added in. So assuming something like:
git svn clone X
cd X
I have had success getting all the externals with the following command:
git svn show-externals | \
perl -ne 'if (/^\/(.*) (.*)/) { print "git svn clone $1 $2\n"; }' | \
bash
I guess a more complicated structure for externals would require a more complicated perl script. Also, if your externals change you will need to do something similar again.

- 2,798
- 23
- 20
-
I found the above technique very useful - except I had to reverse $2 and $1 (the local dir and the remote) – tutuDajuju Nov 13 '13 at 07:01
-
@tutuDajuju glad to hear it helped. Thanks for commenting. I have noticed that too but I haven't spent the time to investigate why the ordering changes in some cases. – Bowie Owens Nov 14 '13 at 03:55
-
Perhaps the clone syntax changed between version? Today it's clone $url [$target_dir] (dir is optional) – tutuDajuju Nov 14 '13 at 10:36
-
This doesn't seem to work if the external is a relative URL. `^/OS/blah/blah` shows up as `/trunk/^/OS/blah/blah` with `git svn show-externals`. Furthermore, `git svn clone` doesn't work on either `/trunk/^/OS/blah/blah` or `^/OS/blah/blah`. However, I can of course clone the external using the full path. – Patrick Apr 24 '15 at 16:27
I post solution here that works in my case
git svn show-externals | \
awk '/^\// { print "git svn clone "$3" ."$1" "$2":HEAD" }' | \
bash

- 137,073
- 23
- 153
- 219

- 56
- 5