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 master.
189
190       set-url [--] <path> <newurl>
191           Sets the URL of the specified submodule to <newurl>. Then, it will
192           automatically synchronize the submodule’s new remote URL
193           configuration.
194
195       summary [--cached|--files] [(-n|--summary-limit) <n>] [commit] [--]
196       [<path>...]
197           Show commit summary between the given commit (defaults to HEAD) and
198           working tree/index. For a submodule in question, a series of
199           commits in the submodule between the given super project commit and
200           the index or working tree (switched by --cached) are shown. If the
201           option --files is given, show the series of commits in the
202           submodule between the index of the super project and the working
203           tree of the submodule (this option doesn’t allow to use the
204           --cached option or to provide an explicit commit).
205
206           Using the --submodule=log option with git-diff(1) will provide that
207           information too.
208
209       foreach [--recursive] <command>
210           Evaluates an arbitrary shell command in each checked out submodule.
211           The command has access to the variables $name, $sm_path,
212           $displaypath, $sha1 and $toplevel: $name is the name of the
213           relevant submodule section in .gitmodules, $sm_path is the path of
214           the submodule as recorded in the immediate superproject,
215           $displaypath contains the relative path from the current working
216           directory to the submodules root directory, $sha1 is the commit as
217           recorded in the immediate superproject, and $toplevel is the
218           absolute path to the top-level of the immediate superproject. Note
219           that to avoid conflicts with $PATH on Windows, the $path variable
220           is now a deprecated synonym of $sm_path variable. Any submodules
221           defined in the superproject but not checked out are ignored by this
222           command. Unless given --quiet, foreach prints the name of each
223           submodule before evaluating the command. If --recursive is given,
224           submodules are traversed recursively (i.e. the given shell command
225           is evaluated in nested submodules as well). A non-zero return from
226           the command in any submodule causes the processing to terminate.
227           This can be overridden by adding || : to the end of the command.
228
229           As an example, the command below will show the path and currently
230           checked out commit for each submodule:
231
232               git submodule foreach 'echo $sm_path `git rev-parse HEAD`'
233
234       sync [--recursive] [--] [<path>...]
235           Synchronizes submodules' remote URL configuration setting to the
236           value specified in .gitmodules. It will only affect those
237           submodules which already have a URL entry in .git/config (that is
238           the case when they are initialized or freshly added). This is
239           useful when submodule URLs change upstream and you need to update
240           your local repositories accordingly.
241
242           git submodule sync synchronizes all submodules while git submodule
243           sync -- A synchronizes submodule "A" only.
244
245           If --recursive is specified, this command will recurse into the
246           registered submodules, and sync any nested submodules within.
247
248       absorbgitdirs
249           If a git directory of a submodule is inside the submodule, move the
250           git directory of the submodule into its superproject’s
251           $GIT_DIR/modules path and then connect the git directory and its
252           working directory by setting the core.worktree and adding a .git
253           file pointing to the git directory embedded in the superprojects
254           git directory.
255
256           A repository that was cloned independently and later added as a
257           submodule or old setups have the submodules git directory inside
258           the submodule instead of embedded into the superprojects git
259           directory.
260
261           This command is recursive by default.
262

OPTIONS

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

FILES

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

SEE ALSO

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

GIT

444       Part of the git(1) suite
445
446
447
448Git 2.26.2                        2020-04-20                  GIT-SUBMODULE(1)
Impressum