gitgithubgit-submodules

Private folder (submodule) in a public repo


I have a public repository. In it I want to use a submodule that is private. If i include this submodule into my public repo, will everyone be able to see the contents of that submodule?


Solution

  • No: Including a submodule in a public repository means recording its URL in a public .gitmodules file.

    The repository at that URL will not be any more accessible through a recursive clone of your repository than it is on its own.

    That is why, for instance, using submodules with GitHub Pages is not possible:

    You can only use submodules with GitHub Pages sites that point to public repositories.
    Using a submodule that points to a private repository is not possible because the Pages server cannot access private repositories.