How to add a specific folder from git repository as a submodule of git?

I have a git repo and I want to add a submodule to it. The problem is that the submodule exists as a folder inside another repo. Can I add only this folder as a submodule?

+30
git git-submodules
Jul 01 '10 at 14:13
source share
2 answers

If you really need to include part of another repository in the history of your own repo, then a more efficient merge strategy is more adequate than submodules.

But in both cases, the full repository is associated with your repo, and not just with one directory.
And partial cloning is not possible .

You can try and isolate this directory in your own repository, and then add it as a submodule, but this means that its history will be completely separate from the repo that happened originally.

+21
Jul 01 '10 at 14:39
source share

I ended up with this:

  • Create a submodules directory.
  • Add the submodule to this directory.
  • Create a symbolic link to a specific directory inside the submodule.

Thus, you have the default behavior of the submodule Git, and in your project you use only a subset of the entire submodule.

+35
Sep 03 '13 at 10:36 on
source share



All Articles