I have a project which use an external library hosted on GitHub. The external library is mine, but it needs to have an own repo because I use it in several projects. This library has the source code I need and a little demo in it. How can I do if I want to add as a submodule only the source code without the rest of the project (such as the demo files)? Is it possible? What is the best solution?
Asked
Active
Viewed 2,504 times
2
-
Sparse checkout should be solution http://stackoverflow.com/a/13738951/1351828 – Adrian Krupa Aug 03 '13 at 14:19
-
http://stackoverflow.com/questions/6238590/set-git-submodule-to-shallow-clone-sparse-checkout – Joe Aug 03 '13 at 15:05
1 Answers
0
The two parts could also be separated as project - sub-project(submodule), such that you can take which ever part you need.
It will depend on your viewpoint as to whether the examples are a sub-project (submodule) of the library, which only need to be populated when required.
Or the examples should have the library as a sub-project (submodule) so as to demonstrate how it's done.
The latter choice is more logical, but you end up with a circular reference within the library's README file where it points to the example project, which includes itself!

Philip Oakley
- 13,333
- 9
- 48
- 71
-
The first solution you propose is interesting, but I should have 2 repos for the library in that way, right? One for the library itself, another for the demo project. And if I want to make the code open source, the users have to download two different projects, right? – Andrea Mario Lufino Aug 04 '13 at 11:34
-
Yes, it would be two repos, with users able to either select the raw library repo, or select the example repo (which would have the library as a sub-module, so would be fetched separately with one of the `submodule update` variants) – Philip Oakley Aug 04 '13 at 18:51