Reputation: 1364
I'm trying to get just a folder from an external github repo to use in my project.
I want my project setup to be like this:
-my_project
-submodule
-code.py
-MY_README
-.git
And I have the remote repo named some-submodule with following structure:
-submodule
-code.py
-README
-.gitignore
So I just want the submodule folder added to my project.
But I end up with this after
git submodule add http://github.com/user/submodule.git submodule
-my_project
-submodule
-submodule
-code.py
-README
-.gitignore
-MY_README
-.gitignore
I am new to git so I really don't know if it possible using just git. If it is of some help I'm using msysgit on windows.
So, is there anyway that I can get a clean submodule folder in my project from a public repo?
If you're curious of exactly what I'm trying to do I'm trying to take directly from their repos these django plugins 1 2 to add them to my project.
Upvotes: 126
Views: 108211
Reputation: 1
This is now possible with sparse-checkout and symbolic links. For more details on how this works, please check out this gist
https://gist.github.com/ZhuoyunZhong/2c08c8549616e03b7f508fea64130558
The general idea is that you first add the submodule, then set up sparse-checkout in the submodule to track only the folders or files you need. Then you could use symbolic links to "place" the folder wherever you want.
Upvotes: 0
Reputation: 165
just
git submodule update --init --recursive
in the root-directory of your project and it should do what you want
Upvotes: -6
Reputation: 1240
What you want to do is not feasible because you cannot clone a part of a repository.
See details in duplicate How to change a git submodule to point to a subfolder?
Upvotes: 68
Reputation: 1323453
If you:
git submodule add http://github.com/user/submodule.git
directly under my_project
, you should end up with the desired organization of directories.
From git submodule add
man page:
The optional argument
<path>
is the relative location for the cloned submodule to exist in the superproject.
If<path>
is not given, the "humanish" part of the source repository is used ("repo" for "/path/to/repo.git
" and "foo
" for "host.xz:foo/.git
").
Upvotes: 9