git svn clone except a particular folder

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

Answers


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.


You can use the --ignore-paths=<regex> option to git svn init or git svn fetch, or add the config option svn-remote.<name>.ignore-paths to .git/config. This is documented as "This allows one to specify a Perl regular expression that will cause skipping of all matching paths from checkout from SVN." Search the manual for "ignore-paths" for more details.

After trying the experiment in this answer, I learned that the regex appears to be applied to the full path of each directory or file from the repository root. Therefore, if you have a standard repository layout and want to exclude the same thing from each trunk/branch/tag, you can use a regex like ^(trunk|((branches|tags)/[^/]+))(<file-to-ignore>|<other-file-to-ignore>).


Need Your Help

How can I restrict file types in SharePoint 2010, Any Tutorial

sharepoint-2010 file-type

I would need to restrict some file types in sharepoint 2010 like rft's etc.

Given a set of N values that are all 0 or X, except for one Y, what is the most efficient way to find X?

redundancy error-correction

Basically I have a set of redundant data that could have an error in one (bonus points: one or more) of the values. Some values could also be 0, which means ignore/invalid. What would be the most