Reputation: 21156
I have a small c++ header-only utilities library that is roughly organized like hits:
my_lib_root\
- my_lib # actual library headers
- test_src # unit test files
- proj # project files for the unit tests and development (e.g. visual studio solution file)
- ... # some more files like readme, ci config, clang_format ...
When I want to use it in another project, I usually just add this library as a submodule and add my_lib_root
to the include paths (so I can access the headers via #include <my_lib/header1.h>
):
my_app\
- libs\
- my_lib_root\
- my_lib
- test_src
- ...
- src
- ...
However, this pulls in a lot of stuff, which is only relevant when I'm doing the actual development of my_lib, so I wonder, if there is a way to only checkout the my_lib
subfolder:
my_app\
- libs\
- my_lib_root\
- my_lib
- src
- ...
Ideally, I'd even like to get rid of my_lib_root
completely:
my_app\
- libs\
- my_lib
- src
- ...
Is there any way in git to achieve one of the above two results?
Upvotes: 2
Views: 1066
Reputation: 3947
You can do this using sparse-checkout.
There is a already a question about this in SO. Check this out. How do I clone a subdirectory only of a Git repository?
Upvotes: 1