git svn clone of a single directory of SVN repository
Solution 1
You don't want the standard layout, you want something like this:
git svn clone svn+ssh://path/to/repo/ --trunk=trunk/directory --branches=branches/*/directory --tags=tags/*/directory
Solution 2
Prepare and enter the local project directory:
mkdir local/project/path
cd local/project/path
Initialize the local git repository with svn remote and fetch the data:
git svn init http://my_svn_server.com/repository/project/location
git svn fetch
Credit goes to Gabriel Saldaña: http://blog.gabrielsaldana.org/using-git-with-subversion-repository-subdirectory/
oconnor0
Updated on July 09, 2022Comments
-
oconnor0 almost 2 years
I am attempting to use
git svn
to clone a single directory of a SVN repository into a Git repository.If I use
git svn clone svn+ssh://path/to/repo/trunk/directory
, I get a Git repo without branches that mirror the branches in the source SVN repo.If I use
git svn --stdlayout svn+ssh://path/to/repo/trunk/directory
, I get an empty Git repo. The following is the output of the command:Initialized empty Git repository in /directory/.git/ Using higher level of URL: svn+ssh://path/to/repo/trunk/directory => svn+ssh://path/to/repo W: Ignoring error from SVN, path probably does not exist: (160013): Filesystem has no item: File not found: revision 100, path '/trunk/directory' W: Do not be alarmed at the above message git-svn is just searching aggressively for old history. This may take a while on large repositories
I had read that the way to fix the above was to add a revision range like
-r 1000:HEAD
, this still produces an empty repo. The output is:Initialized empty Git repository in /directory/.git/ Using higher level of URL: svn+ssh://path/to/repo/trunk/directory => svn+ssh://path/to/repo
Any ideas on how to clone a subdirectory of an SVN repository using git-svn that still grabs all of the branches & tags from the source SVN respository?
-
Stephen Harrison almost 9 yearsThe insight here is that you can use wildcard characters in the
--branches
argument. Good one. -
Nux over 8 yearsJust a note -- if you don't have branches nor tags for that specific directory then you can safely omit
--branches
and--tags
parameters. That is just using--trunk=...
instead of--stdlayout
should work fine. -
Nux over 8 yearsNote that this does not allow adding user (authors) mapping file. At least not with
-A
. -
MarkHu almost 8 yearsThis is practically no different than the one-step
git svn clone
usually. -
Warpzit about 7 yearsThis did the trick. The other thing that also seems to work is git svn clone --no-metadata...
-
Patrick Bergner almost 6 yearsCan I do this with multiple
directory
values instead of only one? At best with a list of specific directory names. Background: Splitting up a single SVN repository by sub-directories into multiple Git repositories (while only migrating the history for these sub-directories and not the whole SVN repository). -
PaulNUK almost 6 yearsDoes that just get you the current contents of the svn project or all the history too ?
-
Steve Smith about 2 yearsDaft question, but what do I do after this? I have an empty folder with a .git folder in it. How do I get at the source I checked out?