GIT: add only some files from remote repository as submodule

git

Solution

It is possible and I've done it many times.

All you need to do is to create a branch of the repository that you are adding as a submodule and strip out all the code that you don't want and add the submodule with that branch.

As an example, look at this repository

Problem

I need to add some JS library to my project and I also want to have ability to update that library from it's repo (that's why I'm adding it as submodule). But I need only on 1 file from that repo to be placed withing my JS directory, whereas library repository contain tests, coffeescript sources and so on, which I do not need in my repository. So the question is - how to add not whole repo as submodule, but single file/directory from it? I suppose this is somehow possible with help of Git Sparse checkouts but not sure if I'm on the right way with this...

Original source

Related problems