1GIT-SUBMODULE(1)                  Git Manual                  GIT-SUBMODULE(1)
2
3
4

NAME

6       git-submodule - Initialize, update or inspect submodules
7

SYNOPSIS

9       git submodule [--quiet] [--cached]
10       git submodule [--quiet] add [<options>] [--] <repository> [<path>]
11       git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
12       git submodule [--quiet] init [--] [<path>...]
13       git submodule [--quiet] deinit [-f|--force] (--all|[--] <path>...)
14       git submodule [--quiet] update [<options>] [--] [<path>...]
15       git submodule [--quiet] set-branch [<options>] [--] <path>
16       git submodule [--quiet] set-url [--] <path> <newurl>
17       git submodule [--quiet] summary [<options>] [--] [<path>...]
18       git submodule [--quiet] foreach [--recursive] <command>
19       git submodule [--quiet] sync [--recursive] [--] [<path>...]
20       git submodule [--quiet] absorbgitdirs [--] [<path>...]
21

DESCRIPTION

23       Inspects, updates and manages submodules.
24
25       For more information about submodules, see gitsubmodules(7).
26

COMMANDS

28       With no arguments, shows the status of existing submodules. Several
29       subcommands are available to perform operations on the submodules.
30
31       add [-b <branch>] [-f|--force] [--name <name>] [--reference
32       <repository>] [--depth <depth>] [--] <repository> [<path>]
33           Add the given repository as a submodule at the given path to the
34           changeset to be committed next to the current project: the current
35           project is termed the "superproject".
36
37           <repository> is the URL of the new submodule’s origin repository.
38           This may be either an absolute URL, or (if it begins with ./ or
39           ../), the location relative to the superproject’s default remote
40           repository (Please note that to specify a repository foo.git which
41           is located right next to a superproject bar.git, you’ll have to use
42           ../foo.git instead of ./foo.git - as one might expect when
43           following the rules for relative URLs - because the evaluation of
44           relative URLs in Git is identical to that of relative directories).
45
46           The default remote is the remote of the remote-tracking branch of
47           the current branch. If no such remote-tracking branch exists or the
48           HEAD is detached, "origin" is assumed to be the default remote. If
49           the superproject doesn’t have a default remote configured the
50           superproject is its own authoritative upstream and the current
51           working directory is used instead.
52
53           The optional argument <path> is the relative location for the
54           cloned submodule to exist in the superproject. If <path> is not
55           given, the canonical part of the source repository is used ("repo"
56           for "/path/to/repo.git" and "foo" for "host.xz:foo/.git"). If
57           <path> exists and is already a valid Git repository, then it is
58           staged for commit without cloning. The <path> is also used as the
59           submodule’s logical name in its configuration entries unless --name
60           is used to specify a logical name.
61
62           The given URL is recorded into .gitmodules for use by subsequent
63           users cloning the superproject. If the URL is given relative to the
64           superproject’s repository, the presumption is the superproject and
65           submodule repositories will be kept together in the same relative
66           location, and only the superproject’s URL needs to be provided.
67           git-submodule will correctly locate the submodule using the
68           relative URL in .gitmodules.
69
70       status [--cached] [--recursive] [--] [<path>...]
71           Show the status of the submodules. This will print the SHA-1 of the
72           currently checked out commit for each submodule, along with the
73           submodule path and the output of git describe for the SHA-1. Each
74           SHA-1 will possibly be prefixed with - if the submodule is not
75           initialized, + if the currently checked out submodule commit does
76           not match the SHA-1 found in the index of the containing repository
77           and U if the submodule has merge conflicts.
78
79           If --cached is specified, this command will instead print the SHA-1
80           recorded in the superproject for each submodule.
81
82           If --recursive is specified, this command will recurse into nested
83           submodules, and show their status as well.
84
85           If you are only interested in changes of the currently initialized
86           submodules with respect to the commit recorded in the index or the
87           HEAD, git-status(1) and git-diff(1) will provide that information
88           too (and can also report changes to a submodule’s work tree).
89
90       init [--] [<path>...]
91           Initialize the submodules recorded in the index (which were added
92           and committed elsewhere) by setting submodule.$name.url in
93           .git/config. It uses the same setting from .gitmodules as a
94           template. If the URL is relative, it will be resolved using the
95           default remote. If there is no default remote, the current
96           repository will be assumed to be upstream.
97
98           Optional <path> arguments limit which submodules will be
99           initialized. If no path is specified and submodule.active has been
100           configured, submodules configured to be active will be initialized,
101           otherwise all submodules are initialized.
102
103           When present, it will also copy the value of
104           submodule.$name.update. This command does not alter existing
105           information in .git/config. You can then customize the submodule
106           clone URLs in .git/config for your local setup and proceed to git
107           submodule update; you can also just use git submodule update --init
108           without the explicit init step if you do not intend to customize
109           any submodule locations.
110
111           See the add subcommand for the definition of default remote.
112
113       deinit [-f|--force] (--all|[--] <path>...)
114           Unregister the given submodules, i.e. remove the whole
115           submodule.$name section from .git/config together with their work
116           tree. Further calls to git submodule update, git submodule foreach
117           and git submodule sync will skip any unregistered submodules until
118           they are initialized again, so use this command if you don’t want
119           to have a local checkout of the submodule in your working tree
120           anymore.
121
122           When the command is run without pathspec, it errors out, instead of
123           deinit-ing everything, to prevent mistakes.
124
125           If --force is specified, the submodule’s working tree will be
126           removed even if it contains local modifications.
127
128           If you really want to remove a submodule from the repository and
129           commit that use git-rm(1) instead. See gitsubmodules(7) for removal
130           options.
131
132       update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow]
133       [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>]
134       [--depth <depth>] [--recursive] [--jobs <n>] [--[no-]single-branch]
135       [--] [<path>...]
136           Update the registered submodules to match what the superproject
137           expects by cloning missing submodules, fetching missing commits in
138           submodules and updating the working tree of the submodules. The
139           "updating" can be done in several ways depending on command line
140           options and the value of submodule.<name>.update configuration
141           variable. The command line option takes precedence over the
142           configuration variable. If neither is given, a checkout is
143           performed. The update procedures supported both from the command
144           line as well as through the submodule.<name>.update configuration
145           are:
146
147           checkout
148               the commit recorded in the superproject will be checked out in
149               the submodule on a detached HEAD.
150
151               If --force is specified, the submodule will be checked out
152               (using git checkout --force), even if the commit specified in
153               the index of the containing repository already matches the
154               commit checked out in the submodule.
155
156           rebase
157               the current branch of the submodule will be rebased onto the
158               commit recorded in the superproject.
159
160           merge
161               the commit recorded in the superproject will be merged into the
162               current branch in the submodule.
163
164           The following update procedures are only available via the
165           submodule.<name>.update configuration variable:
166
167           custom command
168               arbitrary shell command that takes a single argument (the sha1
169               of the commit recorded in the superproject) is executed. When
170               submodule.<name>.update is set to !command, the remainder after
171               the exclamation mark is the custom command.
172
173           none
174               the submodule is not updated.
175
176           If the submodule is not yet initialized, and you just want to use
177           the setting as stored in .gitmodules, you can automatically
178           initialize the submodule with the --init option.
179
180           If --recursive is specified, this command will recurse into the
181           registered submodules, and update any nested submodules within.
182
183       set-branch (-b|--branch) <branch> [--] <path>, set-branch
184       (-d|--default) [--] <path>
185           Sets the default remote tracking branch for the submodule. The
186           --branch option allows the remote branch to be specified. The
187           --default option removes the submodule.<name>.branch configuration
188           key, which causes the tracking branch to default to the remote
189           HEAD.
190
191       set-url [--] <path> <newurl>
192           Sets the URL of the specified submodule to <newurl>. Then, it will
193           automatically synchronize the submodule’s new remote URL
194           configuration.
195
196       summary [--cached|--files] [(-n|--summary-limit) <n>] [commit] [--]
197       [<path>...]
198           Show commit summary between the given commit (defaults to HEAD) and
199           working tree/index. For a submodule in question, a series of
200           commits in the submodule between the given super project commit and
201           the index or working tree (switched by --cached) are shown. If the
202           option --files is given, show the series of commits in the
203           submodule between the index of the super project and the working
204           tree of the submodule (this option doesn’t allow to use the
205           --cached option or to provide an explicit commit).
206
207           Using the --submodule=log option with git-diff(1) will provide that
208           information too.
209
210       foreach [--recursive] <command>
211           Evaluates an arbitrary shell command in each checked out submodule.
212           The command has access to the variables $name, $sm_path,
213           $displaypath, $sha1 and $toplevel: $name is the name of the
214           relevant submodule section in .gitmodules, $sm_path is the path of
215           the submodule as recorded in the immediate superproject,
216           $displaypath contains the relative path from the current working
217           directory to the submodules root directory, $sha1 is the commit as
218           recorded in the immediate superproject, and $toplevel is the
219           absolute path to the top-level of the immediate superproject. Note
220           that to avoid conflicts with $PATH on Windows, the $path variable
221           is now a deprecated synonym of $sm_path variable. Any submodules
222           defined in the superproject but not checked out are ignored by this
223           command. Unless given --quiet, foreach prints the name of each
224           submodule before evaluating the command. If --recursive is given,
225           submodules are traversed recursively (i.e. the given shell command
226           is evaluated in nested submodules as well). A non-zero return from
227           the command in any submodule causes the processing to terminate.
228           This can be overridden by adding || : to the end of the command.
229
230           As an example, the command below will show the path and currently
231           checked out commit for each submodule:
232
233               git submodule foreach 'echo $sm_path `git rev-parse HEAD`'
234
235       sync [--recursive] [--] [<path>...]
236           Synchronizes submodules' remote URL configuration setting to the
237           value specified in .gitmodules. It will only affect those
238           submodules which already have a URL entry in .git/config (that is
239           the case when they are initialized or freshly added). This is
240           useful when submodule URLs change upstream and you need to update
241           your local repositories accordingly.
242
243           git submodule sync synchronizes all submodules while git submodule
244           sync -- A synchronizes submodule "A" only.
245
246           If --recursive is specified, this command will recurse into the
247           registered submodules, and sync any nested submodules within.
248
249       absorbgitdirs
250           If a git directory of a submodule is inside the submodule, move the
251           git directory of the submodule into its superproject’s
252           $GIT_DIR/modules path and then connect the git directory and its
253           working directory by setting the core.worktree and adding a .git
254           file pointing to the git directory embedded in the superprojects
255           git directory.
256
257           A repository that was cloned independently and later added as a
258           submodule or old setups have the submodules git directory inside
259           the submodule instead of embedded into the superprojects git
260           directory.
261
262           This command is recursive by default.
263

OPTIONS

265       -q, --quiet
266           Only print error messages.
267
268       --progress
269           This option is only valid for add and update commands. Progress
270           status is reported on the standard error stream by default when it
271           is attached to a terminal, unless -q is specified. This flag forces
272           progress status even if the standard error stream is not directed
273           to a terminal.
274
275       --all
276           This option is only valid for the deinit command. Unregister all
277           submodules in the working tree.
278
279       -b <branch>, --branch <branch>
280           Branch of repository to add as submodule. The name of the branch is
281           recorded as submodule.<name>.branch in .gitmodules for update
282           --remote. A special value of .  is used to indicate that the name
283           of the branch in the submodule should be the same name as the
284           current branch in the current repository. If the option is not
285           specified, it defaults to the remote HEAD.
286
287       -f, --force
288           This option is only valid for add, deinit and update commands. When
289           running add, allow adding an otherwise ignored submodule path. When
290           running deinit the submodule working trees will be removed even if
291           they contain local changes. When running update (only effective
292           with the checkout procedure), throw away local changes in
293           submodules when switching to a different commit; and always run a
294           checkout operation in the submodule, even if the commit listed in
295           the index of the containing repository matches the commit checked
296           out in the submodule.
297
298       --cached
299           This option is only valid for status and summary commands. These
300           commands typically use the commit found in the submodule HEAD, but
301           with this option, the commit stored in the index is used instead.
302
303       --files
304           This option is only valid for the summary command. This command
305           compares the commit in the index with that in the submodule HEAD
306           when this option is used.
307
308       -n, --summary-limit
309           This option is only valid for the summary command. Limit the
310           summary size (number of commits shown in total). Giving 0 will
311           disable the summary; a negative number means unlimited (the
312           default). This limit only applies to modified submodules. The size
313           is always limited to 1 for added/deleted/typechanged submodules.
314
315       --remote
316           This option is only valid for the update command. Instead of using
317           the superproject’s recorded SHA-1 to update the submodule, use the
318           status of the submodule’s remote-tracking branch. The remote used
319           is branch’s remote (branch.<name>.remote), defaulting to origin.
320           The remote branch used defaults to the remote HEAD, but the branch
321           name may be overridden by setting the submodule.<name>.branch
322           option in either .gitmodules or .git/config (with .git/config
323           taking precedence).
324
325           This works for any of the supported update procedures (--checkout,
326           --rebase, etc.). The only change is the source of the target SHA-1.
327           For example, submodule update --remote --merge will merge upstream
328           submodule changes into the submodules, while submodule update
329           --merge will merge superproject gitlink changes into the
330           submodules.
331
332           In order to ensure a current tracking branch state, update --remote
333           fetches the submodule’s remote repository before calculating the
334           SHA-1. If you don’t want to fetch, you should use submodule update
335           --remote --no-fetch.
336
337           Use this option to integrate changes from the upstream subproject
338           with your submodule’s current HEAD. Alternatively, you can run git
339           pull from the submodule, which is equivalent except for the remote
340           branch name: update --remote uses the default upstream repository
341           and submodule.<name>.branch, while git pull uses the submodule’s
342           branch.<name>.merge. Prefer submodule.<name>.branch if you want to
343           distribute the default upstream branch with the superproject and
344           branch.<name>.merge if you want a more native feel while working in
345           the submodule itself.
346
347       -N, --no-fetch
348           This option is only valid for the update command. Don’t fetch new
349           objects from the remote site.
350
351       --checkout
352           This option is only valid for the update command. Checkout the
353           commit recorded in the superproject on a detached HEAD in the
354           submodule. This is the default behavior, the main use of this
355           option is to override submodule.$name.update when set to a value
356           other than checkout. If the key submodule.$name.update is either
357           not explicitly set or set to checkout, this option is implicit.
358
359       --merge
360           This option is only valid for the update command. Merge the commit
361           recorded in the superproject into the current branch of the
362           submodule. If this option is given, the submodule’s HEAD will not
363           be detached. If a merge failure prevents this process, you will
364           have to resolve the resulting conflicts within the submodule with
365           the usual conflict resolution tools. If the key
366           submodule.$name.update is set to merge, this option is implicit.
367
368       --rebase
369           This option is only valid for the update command. Rebase the
370           current branch onto the commit recorded in the superproject. If
371           this option is given, the submodule’s HEAD will not be detached. If
372           a merge failure prevents this process, you will have to resolve
373           these failures with git-rebase(1). If the key
374           submodule.$name.update is set to rebase, this option is implicit.
375
376       --init
377           This option is only valid for the update command. Initialize all
378           submodules for which "git submodule init" has not been called so
379           far before updating.
380
381       --name
382           This option is only valid for the add command. It sets the
383           submodule’s name to the given string instead of defaulting to its
384           path. The name must be valid as a directory name and may not end
385           with a /.
386
387       --reference <repository>
388           This option is only valid for add and update commands. These
389           commands sometimes need to clone a remote repository. In this case,
390           this option will be passed to the git-clone(1) command.
391
392           NOTE: Do not use this option unless you have read the note for git-
393           clone(1)'s --reference, --shared, and --dissociate options
394           carefully.
395
396       --dissociate
397           This option is only valid for add and update commands. These
398           commands sometimes need to clone a remote repository. In this case,
399           this option will be passed to the git-clone(1) command.
400
401           NOTE: see the NOTE for the --reference option.
402
403       --recursive
404           This option is only valid for foreach, update, status and sync
405           commands. Traverse submodules recursively. The operation is
406           performed not only in the submodules of the current repo, but also
407           in any nested submodules inside those submodules (and so on).
408
409       --depth
410           This option is valid for add and update commands. Create a shallow
411           clone with a history truncated to the specified number of
412           revisions. See git-clone(1)
413
414       --[no-]recommend-shallow
415           This option is only valid for the update command. The initial clone
416           of a submodule will use the recommended submodule.<name>.shallow as
417           provided by the .gitmodules file by default. To ignore the
418           suggestions use --no-recommend-shallow.
419
420       -j <n>, --jobs <n>
421           This option is only valid for the update command. Clone new
422           submodules in parallel with as many jobs. Defaults to the
423           submodule.fetchJobs option.
424
425       --[no-]single-branch
426           This option is only valid for the update command. Clone only one
427           branch during update: HEAD or one specified by --branch.
428
429       <path>...
430           Paths to submodule(s). When specified this will restrict the
431           command to only operate on the submodules found at the specified
432           paths. (This argument is required with add).
433

FILES

435       When initializing submodules, a .gitmodules file in the top-level
436       directory of the containing repository is used to find the url of each
437       submodule. This file should be formatted in the same way as
438       $GIT_DIR/config. The key to each submodule url is
439       "submodule.$name.url". See gitmodules(5) for details.
440

SEE ALSO

442       gitsubmodules(7), gitmodules(5).
443

GIT

445       Part of the git(1) suite
446
447
448
449Git 2.30.2                        2021-03-08                  GIT-SUBMODULE(1)
Impressum