views:

165

answers:

1

I want to git clone an svn repository except for one folder in the root folder of svn.

How do I do it?

I could do git svn clone svnrepo/dir/sb-dir/ if I needed only sb-dir but I need all folders (and files) within the dir except the design folder

+1  A: 

If you are using the latest Git1.7.0, it offers a sparse checkout feature.

"sparse checkout" feature allows only part of the work tree to be checked out.

See Git Sparse Checkout SO question for more: you still need to clone the all repo, but you can checkout (i.e. fill your working tree) with only parts of the cloned repo)


The only other way would to transform design as a submodule.
As the GitPro book mentions:

Git's submodule support allows a repository to contain, as a subdirectory, a checkout of an external project.
Submodules maintain their own identity; the submodule support just stores the submodule repository location and commit ID, so other developers who clone the containing project ("superproject") can easily clone all the submodules at the same revision.
Partial checkouts of the superproject are possible: you can tell Git to clone none, some or all of the submodules.

Submodule is the only way I am aware to achieve "partial cloning", since n your case it is the cloning part which is problematic.
From your comments:

my problem is that design folder is some 700 mb; and it takes hours to git svn clone. Whole of the rest of the project put together is in 10s of mb.

But that means modifying the SVN repo, to isolate design as an "external" reference, then git svn clone and add in the cloned Git repo a submodule reference.

VonC
Thanks! But my problem is that design folder is some 700 mb; and it takes hours to git svn clone. Whole of the rest of the project put together is in 10s of mb. It is wrong in the first place I know, to put it in repo. But I wanted some sane way to deal locally using git. Doesn;t seem possible, then
Lakshman Prasad
@becomingGuru: the sane way would be to split that repo and isolate design in its own repo, referenced as a submodule. That way, you would achieve *exactly* what you are looking for. See http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository
VonC