Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git svn clone of a single directory of SVN repository

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?

like image 503
oconnor0 Avatar asked Jul 25 '13 17:07

oconnor0


People also ask

How do I clone a SVN repository?

# Clone a repo with standard SVN directory layout (like git clone): git svn clone http://svn.example.com/project --stdlayout --prefix svn/ # Or, if the repo uses a non-standard directory layout: git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ # View all branches and tags you have ...

What does git SVN clone do?

The git svn clone command transforms the trunk, branches, and tags in your SVN repository into a new Git repository. Depending on the structure of your SVN repo, the command needs to be configured differently.


2 Answers

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 
like image 116
Mykola Gurov Avatar answered Sep 22 '22 12:09

Mykola Gurov


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/

like image 31
Adrian Constantin Avatar answered Sep 23 '22 12:09

Adrian Constantin