How to clone only a folder from a git submodule?

I am trying to get only a folder from an external github repository for use in my project.

I want my project setup to be like this:

-my_project -submodule -code.py -MY_README -.git 

And I have a remote repo with a submodule name with the following structure:

 -submodule -code.py -README -.gitignore 

So, I just want the submodule folder to be added to my project.

But I get it after

  git subodule add http://github.com/user/submodule.git submodule 
 -my_project -submodule -submodule -code.py -README -.gitignore -MY_README -.gitignore 

I'm new to git, so I really don't know if only git can be used. If that helps, I use msysgit for windows.

So, is there anyway that I can get a clean submodule folder in my project from a public repo?

If you are interested in what exactly I am trying to do, I try to take these django 1 2 plugins directly from my repositories to add them to my project.

+49
git git-submodules
Oct 05 2018-10-10
source share
2 answers

What you want to do is impractical because you cannot clone part of the repository.

See details in duplicate. How do I change the git submodule to point to a subfolder?

+15
Sep 11
source share

If you:

 git submodule add http://github.com/user/submodule.git 

directly under my_project , you should get the correct directory organization.

From git submodule add man page :

The optional <path> argument is the relative location of the cloned submodule to exist in the superproject.
If <path> not specified, the "humanistic" part of the original repository is used ("repo" for " /path/to/repo.git " and " foo " for " host.xz:foo/.git ").

+5
Oct 05 '10 at 19:34
source share



All Articles