Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 447
lprsd Avatar asked Mar 03 '10 13:03

lprsd


2 Answers

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>)(/|$).

like image 198
Max Nanasy Avatar answered Oct 24 '22 00:10

Max Nanasy


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.

like image 24
VonC Avatar answered Oct 24 '22 00:10

VonC