If you push your branch with a submodule to a shared repository, this means that the public will be able to see the URL of the submodule. Whether the public can see the content of the submodule depends on whether this publication is available to you. For example, if you have this in a private Github repository, the public will be able to see the URL, but will not be able to access the content.
All submodule additions actually put an entry in the url in .gitmodules , it does not insert the contents of this repository. Whether this URL is publicly available is a completely different matter.
If you want to keep even the URL of a private private repository, you will have to work in a separate local branch and never insert this branch into the shared repository. eg.
git clone somePublicRepo cd somePublicRepo git branch neverPushThisBranch git checkout neverPushThisBranch git submodule add privateRepo git submodule update
Since the file that describes which submodules contain the repository ( .gitmodules ) is checked in the same way as any other file in Git, if you check the submodule on a branch, no one sees this submodule unless you click on a branch in a public place.
Thus, different git branches may have a different set of submodules.
With this approach, you need to be sufficiently disciplined in how you work on branches so that you do not accidentally introduce your private branch into the world.
MichaelM
source share