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] add [<options>] [--] <repository> [<path>]
10       git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
11       git submodule [--quiet] init [--] [<path>...]
12       git submodule [--quiet] deinit [-f|--force] (--all|[--] <path>...)
13       git submodule [--quiet] update [<options>] [--] [<path>...]
14       git submodule [--quiet] summary [<options>] [--] [<path>...]
15       git submodule [--quiet] foreach [--recursive] <command>
16       git submodule [--quiet] sync [--recursive] [--] [<path>...]
17       git submodule [--quiet] absorbgitdirs [--] [<path>...]
18
19

DESCRIPTION

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

COMMANDS

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

OPTIONS

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

FILES

404       When initializing submodules, a .gitmodules file in the top-level
405       directory of the containing repository is used to find the url of each
406       submodule. This file should be formatted in the same way as
407       $GIT_DIR/config. The key to each submodule url is
408       "submodule.$name.url". See gitmodules(5) for details.
409

SEE ALSO

411       gitsubmodules(7), gitmodules(5).
412

GIT

414       Part of the git(1) suite
415
416
417
418Git 2.18.1                        05/14/2019                  GIT-SUBMODULE(1)
Impressum