@@ -36,8 +36,8 @@ The `gitlink` entry contains the object name of the commit that the
3636superproject expects the submodule’s working directory to be at.
3737
3838The section `submodule.foo.*` in the `.gitmodules` file gives additional
39- hints to Gits porcelain layer such as where to obtain the submodule via
40- the ` submodule.foo.url` setting .
39+ hints to Git's porcelain layer. For example, the ` submodule.foo.url`
40+ setting specifies where to obtain the submodule.
4141
4242Submodules can be used for at least two different use cases:
4343
@@ -51,18 +51,21 @@ Submodules can be used for at least two different use cases:
5151
52522. Splitting a (logically single) project into multiple
5353 repositories and tying them back together. This can be used to
54- overcome current limitations of Gits implementation to have
54+ overcome current limitations of Git's implementation to have
5555 finer grained access:
5656
57- * Size of the git repository:
57+ * Size of the Git repository:
5858 In its current form Git scales up poorly for large repositories containing
5959 content that is not compressed by delta computation between trees.
60- However you can also use submodules to e.g. hold large binary assets
61- and these repositories are then shallowly cloned such that you do not
60+ For example, you can use submodules to hold large binary assets
61+ and these repositories can be shallowly cloned such that you do not
6262 have a large history locally.
6363 * Transfer size:
6464 In its current form Git requires the whole working tree present. It
6565 does not allow partial trees to be transferred in fetch or clone.
66+ If the project you work on consists of multiple repositories tied
67+ together as submodules in a superproject, you can avoid fetching the
68+ working trees of the repositories you are not interested in.
6669 * Access control:
6770 By restricting user access to submodules, this can be used to implement
6871 read/write policies for different users.
@@ -73,9 +76,10 @@ The configuration of submodules
7376Submodule operations can be configured using the following mechanisms
7477(from highest to lowest precedence):
7578
76- * The command line for those commands that support taking submodule specs.
77- Most commands have a boolean flag '--recurse-submodules' whether to
78- recurse into submodules. Examples are `ls-files` or `checkout`.
79+ * The command line for those commands that support taking submodules
80+ as part of their pathspecs. Most commands have a boolean flag
81+ `--recurse-submodules` which specify whether to recurse into submodules.
82+ Examples are `grep` and `checkout`.
7983 Some commands take enums, such as `fetch` and `push`, where you can
8084 specify how submodules are affected.
8185
@@ -87,8 +91,8 @@ Submodule operations can be configured using the following mechanisms
8791For example an effect from the submodule's `.gitignore` file
8892would be observed when you run `git status --ignore-submodules=none` in
8993the superproject. This collects information from the submodule's working
90- directory by running `status` in the submodule, which does pay attention
91- to its `.gitignore` file.
94+ directory by running `status` in the submodule while paying attention
95+ to the `.gitignore` file of the submodule .
9296+
9397The submodule's `$GIT_DIR/config` file would come into play when running
9498`git push --recurse-submodules=check` in the superproject, as this would
@@ -97,20 +101,20 @@ remotes are configured in the submodule as usual in the `$GIT_DIR/config`
97101file.
98102
99103 * The configuration file `$GIT_DIR/config` in the superproject.
100- Typical configuration at this place is controlling if a submodule
101- is recursed into at all via the `active` flag for example .
104+ Git only recurses into active submodules (see "ACTIVE SUBMODULES"
105+ section below) .
102106+
103107If the submodule is not yet initialized, then the configuration
104- inside the submodule does not exist yet, so configuration where to
108+ inside the submodule does not exist yet, so where to
105109obtain the submodule from is configured here for example.
106110
107- * the `.gitmodules` file inside the superproject. Additionally to the
108- required mapping between submodule's name and path, a project usually
111+ * The `.gitmodules` file inside the superproject. A project usually
109112 uses this file to suggest defaults for the upstream collection
110- of repositories.
113+ of repositories for the mapping that is required between a
114+ submodule's name and its path.
111115+
112- This file mainly serves as the mapping between name and path in
113- the superproject, such that the submodule's git directory can be
116+ This file mainly serves as the mapping between the name and path of submodules
117+ in the superproject, such that the submodule's Git directory can be
114118located.
115119+
116120If the submodule has never been initialized, this is the only place
@@ -137,8 +141,8 @@ directory is automatically moved to `$GIT_DIR/modules/<name>/`
137141of the superproject.
138142
139143 * Deinitialized submodule: A `gitlink`, and a `.gitmodules` entry,
140- but no submodule working directory. The submodule’s git directory
141- may be there as after deinitializing the git directory is kept around.
144+ but no submodule working directory. The submodule’s Git directory
145+ may be there as after deinitializing the Git directory is kept around.
142146The directory which is supposed to be the working directory is empty instead.
143147+
144148A submodule can be deinitialized by running `git submodule deinit`.
@@ -160,6 +164,60 @@ from another repository.
160164To completely remove a submodule, manually delete
161165`$GIT_DIR/modules/<name>/`.
162166
167+ ACTIVE SUBMODULES
168+ -----------------
169+
170+ A submodule is considered active,
171+
172+ (a) if `submodule.<name>.active` is set to `true`
173+ or
174+ (b) if the submodule's path matches the pathspec in `submodule.active`
175+ or
176+ (c) if `submodule.<name>.url` is set.
177+
178+ and these are evaluated in this order.
179+
180+ For example:
181+
182+ [submodule "foo"]
183+ active = false
184+ url = https://example.org/foo
185+ [submodule "bar"]
186+ active = true
187+ url = https://example.org/bar
188+ [submodule "baz"]
189+ url = https://example.org/baz
190+
191+ In the above config only the submodule 'bar' and 'baz' are active,
192+ 'bar' due to (a) and 'baz' due to (c). 'foo' is inactive because
193+ (a) takes precedence over (c)
194+
195+ Note that (c) is a historical artefact and will be ignored if the
196+ (a) and (b) specify that the submodule is not active. In other words,
197+ if we have an `submodule.<name>.active` set to `false` or if the
198+ submodule's path is excluded in the pathspec in `submodule.active`, the
199+ url doesn't matter whether it is present or not. This is illustrated in
200+ the example that follows.
201+
202+ [submodule "foo"]
203+ active = true
204+ url = https://example.org/foo
205+ [submodule "bar"]
206+ url = https://example.org/bar
207+ [submodule "baz"]
208+ url = https://example.org/baz
209+ [submodule "bob"]
210+ ignore = true
211+ [submodule]
212+ active = b*
213+ active = :(exclude) baz
214+
215+ In here all submodules except 'baz' (foo, bar, bob) are active.
216+ 'foo' due to its own active flag and all the others due to the
217+ submodule active pathspec, which specifies that any submodule
218+ starting with 'b' except 'baz' are also active, regardless of the
219+ presence of the .url field.
220+
163221Workflow for a third party library
164222----------------------------------
165223
0 commit comments