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

OPTIONS

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

FILES

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

SEE ALSO

446       gitsubmodules(7), gitmodules(5).
447

GIT

449       Part of the git(1) suite
450
451
452
453Git 2.36.1                        2022-05-05                  GIT-SUBMODULE(1)
Impressum