Adding parts of a git repository as a submodule
- Add the repository as a submodule
git submodule add <url> <path> - Change into the created directory
cd <path> - Initialize a sparse-checkout
git sparse-checkout init --cone - Edit the created sparse-checkout file
vim ~/.git/modules/<module-name>/info/sparse-checkout - Whatever is added into the file will be kept. Can be negated by using
!
!* # ignore all
<path-to>/<file-to-keep>
git sparse-checkout reapply