@@ -200,10 +200,32 @@ directory.
200200SUBMODULES
201201----------
202202
203- If your repository contains one or more submodules, then those submodules will
204- appear based on which you initialized with the `git submodule` command. If
205- your sparse-checkout patterns exclude an initialized submodule, then that
206- submodule will still appear in your working directory.
203+ If your repository contains one or more submodules, then submodules
204+ are populated based on interactions with the `git submodule` command.
205+ Specifically, `git submodule init -- <path>` will ensure the submodule
206+ at `<path>` is present, while `git submodule deinit [-f] -- <path>`
207+ will remove the files for the submodule at `<path>` (including any
208+ untracked files, uncommitted changes, and unpushed history). Similar
209+ to how sparse-checkout removes files from the working tree but still
210+ leaves entries in the index, deinitialized submodules are removed from
211+ the working directory but still have an entry in the index.
212+
213+ Since submodules may have unpushed changes or untracked files,
214+ removing them could result in data loss. Thus, changing sparse
215+ inclusion/exclusion rules will not cause an already checked out
216+ submodule to be removed from the working copy. Said another way, just
217+ as `checkout` will not cause submodules to be automatically removed or
218+ initialized even when switching between branches that remove or add
219+ submodules, using `sparse-checkout` to reduce or expand the scope of
220+ "interesting" files will not cause submodules to be automatically
221+ deinitialized or initialized either.
222+
223+ Further, the above facts mean that there are multiple reasons that
224+ "tracked" files might not be present in the working copy: sparsity
225+ pattern application from sparse-checkout, and submodule initialization
226+ state. Thus, commands like `git grep` that work on tracked files in
227+ the working copy may return results that are limited by either or both
228+ of these restrictions.
207229
208230
209231SEE ALSO
0 commit comments