1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE sect2 SYSTEM "../../../dtd/dblite.dtd">
\r
4 <sect2 lang="en" id="git-submodule(1)">
\r
5 <title>git-submodule(1)</title>
\r
7 <primary>git-submodule(1)</primary>
\r
9 <simplesect id="git-submodule(1)__name">
\r
11 <simpara>git-submodule - Initialize, update or inspect submodules</simpara>
\r
13 <simplesect id="git-submodule(1)__synopsis">
\r
14 <title>SYNOPSIS</title>
\r
16 <literallayout><emphasis>git submodule</emphasis> [--quiet] [--cached]
\r
17 <emphasis>git submodule</emphasis> [--quiet] add [<options>] [--] <repository> [<path>]
\r
18 <emphasis>git submodule</emphasis> [--quiet] status [--cached] [--recursive] [--] [<path>…]
\r
19 <emphasis>git submodule</emphasis> [--quiet] init [--] [<path>…]
\r
20 <emphasis>git submodule</emphasis> [--quiet] deinit [-f|--force] (--all|[--] <path>…)
\r
21 <emphasis>git submodule</emphasis> [--quiet] update [<options>] [--] [<path>…]
\r
22 <emphasis>git submodule</emphasis> [--quiet] set-branch [<options>] [--] <path>
\r
23 <emphasis>git submodule</emphasis> [--quiet] set-url [--] <path> <newurl>
\r
24 <emphasis>git submodule</emphasis> [--quiet] summary [<options>] [--] [<path>…]
\r
25 <emphasis>git submodule</emphasis> [--quiet] foreach [--recursive] <command>
\r
26 <emphasis>git submodule</emphasis> [--quiet] sync [--recursive] [--] [<path>…]
\r
27 <emphasis>git submodule</emphasis> [--quiet] absorbgitdirs [--] [<path>…]</literallayout>
\r
30 <simplesect id="git-submodule(1)__description">
\r
31 <title>DESCRIPTION</title>
\r
32 <simpara>Inspects, updates and manages submodules.</simpara>
\r
33 <simpara>For more information about submodules, see <xref linkend="gitsubmodules(7)" />.</simpara>
\r
35 <simplesect id="git-submodule(1)__commands">
\r
36 <title>COMMANDS</title>
\r
37 <simpara>With no arguments, shows the status of existing submodules. Several
\r
38 subcommands are available to perform operations on the submodules.</simpara>
\r
42 add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--depth <depth>] [--] <repository> [<path>]
\r
46 Add the given repository as a submodule at the given path
\r
47 to the changeset to be committed next to the current
\r
48 project: the current project is termed the "superproject".
\r
50 <simpara><repository> is the URL of the new submodule's origin repository.
\r
51 This may be either an absolute URL, or (if it begins with ./
\r
52 or ../), the location relative to the superproject's default remote
\r
53 repository (Please note that to specify a repository <emphasis>foo.git</emphasis>
\r
54 which is located right next to a superproject <emphasis>bar.git</emphasis>, you'll
\r
55 have to use <emphasis>../foo.git</emphasis> instead of <emphasis>./foo.git</emphasis> - as one might expect
\r
56 when following the rules for relative URLs - because the evaluation
\r
57 of relative URLs in Git is identical to that of relative directories).</simpara>
\r
58 <simpara>The default remote is the remote of the remote-tracking branch
\r
59 of the current branch. If no such remote-tracking branch exists or
\r
60 the HEAD is detached, "origin" is assumed to be the default remote.
\r
61 If the superproject doesn't have a default remote configured
\r
62 the superproject is its own authoritative upstream and the current
\r
63 working directory is used instead.</simpara>
\r
64 <simpara>The optional argument <path> is the relative location for the cloned
\r
65 submodule to exist in the superproject. If <path> is not given, the
\r
66 canonical part of the source repository is used ("repo" for
\r
67 "/path/to/repo.git" and "foo" for "host.xz:foo/.git"). If <path>
\r
68 exists and is already a valid Git repository, then it is staged
\r
69 for commit without cloning. The <path> is also used as the submodule's
\r
70 logical name in its configuration entries unless <emphasis>--name</emphasis> is used
\r
71 to specify a logical name.</simpara>
\r
72 <simpara>The given URL is recorded into <emphasis>.gitmodules</emphasis> for use by subsequent users
\r
73 cloning the superproject. If the URL is given relative to the
\r
74 superproject's repository, the presumption is the superproject and
\r
75 submodule repositories will be kept together in the same relative
\r
76 location, and only the superproject's URL needs to be provided.
\r
77 git-submodule will correctly locate the submodule using the relative
\r
78 URL in <emphasis>.gitmodules</emphasis>.</simpara>
\r
83 status [--cached] [--recursive] [--] [<path>…]
\r
87 Show the status of the submodules. This will print the SHA-1 of the
\r
88 currently checked out commit for each submodule, along with the
\r
89 submodule path and the output of <emphasis>git describe</emphasis> for the
\r
90 SHA-1. Each SHA-1 will possibly be prefixed with <emphasis>-</emphasis> if the submodule is
\r
91 not initialized, <emphasis>+</emphasis> if the currently checked out submodule commit
\r
92 does not match the SHA-1 found in the index of the containing
\r
93 repository and <emphasis>U</emphasis> if the submodule has merge conflicts.
\r
95 <simpara>If <emphasis>--cached</emphasis> is specified, this command will instead print the SHA-1
\r
96 recorded in the superproject for each submodule.</simpara>
\r
97 <simpara>If <emphasis>--recursive</emphasis> is specified, this command will recurse into nested
\r
98 submodules, and show their status as well.</simpara>
\r
99 <simpara>If you are only interested in changes of the currently initialized
\r
100 submodules with respect to the commit recorded in the index or the HEAD,
\r
101 <xref linkend="git-status(1)" /> and <xref linkend="git-diff(1)" /> will provide that information
\r
102 too (and can also report changes to a submodule's work tree).</simpara>
\r
107 init [--] [<path>…]
\r
111 Initialize the submodules recorded in the index (which were
\r
112 added and committed elsewhere) by setting <emphasis>submodule.$name.url</emphasis>
\r
113 in .git/config. It uses the same setting from <emphasis>.gitmodules</emphasis> as
\r
114 a template. If the URL is relative, it will be resolved using
\r
115 the default remote. If there is no default remote, the current
\r
116 repository will be assumed to be upstream.
\r
118 <simpara>Optional <path> arguments limit which submodules will be initialized.
\r
119 If no path is specified and submodule.active has been configured, submodules
\r
120 configured to be active will be initialized, otherwise all submodules are
\r
121 initialized.</simpara>
\r
122 <simpara>When present, it will also copy the value of <emphasis>submodule.$name.update</emphasis>.
\r
123 This command does not alter existing information in .git/config.
\r
124 You can then customize the submodule clone URLs in .git/config
\r
125 for your local setup and proceed to <emphasis>git submodule update</emphasis>;
\r
126 you can also just use <emphasis>git submodule update --init</emphasis> without
\r
127 the explicit <emphasis>init</emphasis> step if you do not intend to customize
\r
128 any submodule locations.</simpara>
\r
129 <simpara>See the add subcommand for the definition of default remote.</simpara>
\r
134 deinit [-f|--force] (--all|[--] <path>…)
\r
138 Unregister the given submodules, i.e. remove the whole
\r
139 <emphasis>submodule.$name</emphasis> section from .git/config together with their work
\r
140 tree. Further calls to <emphasis>git submodule update</emphasis>, <emphasis>git submodule foreach</emphasis>
\r
141 and <emphasis>git submodule sync</emphasis> will skip any unregistered submodules until
\r
142 they are initialized again, so use this command if you don't want to
\r
143 have a local checkout of the submodule in your working tree anymore.
\r
145 <simpara>When the command is run without pathspec, it errors out,
\r
146 instead of deinit-ing everything, to prevent mistakes.</simpara>
\r
147 <simpara>If <emphasis>--force</emphasis> is specified, the submodule's working tree will
\r
148 be removed even if it contains local modifications.</simpara>
\r
149 <simpara>If you really want to remove a submodule from the repository and commit
\r
150 that use <xref linkend="git-rm(1)" /> instead. See <xref linkend="gitsubmodules(7)" /> for removal
\r
156 update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>] [--depth <depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--] [<path>…]
\r
159 <simpara>Update the registered submodules to match what the superproject
\r
160 expects by cloning missing submodules, fetching missing commits
\r
161 in submodules and updating the working tree of
\r
162 the submodules. The "updating" can be done in several ways depending
\r
163 on command line options and the value of <emphasis>submodule.<name>.update</emphasis>
\r
164 configuration variable. The command line option takes precedence over
\r
165 the configuration variable. If neither is given, a <emphasis>checkout</emphasis> is performed.
\r
166 The <emphasis>update</emphasis> procedures supported both from the command line as well as
\r
167 through the <emphasis>submodule.<name>.update</emphasis> configuration are:</simpara>
\r
175 the commit recorded in the superproject will be
\r
176 checked out in the submodule on a detached HEAD.
\r
178 <simpara>If <emphasis>--force</emphasis> is specified, the submodule will be checked out (using
\r
179 <emphasis>git checkout --force</emphasis>), even if the commit specified
\r
180 in the index of the containing repository already matches the commit
\r
181 checked out in the submodule.</simpara>
\r
190 the current branch of the submodule will be rebased
\r
191 onto the commit recorded in the superproject.
\r
201 the commit recorded in the superproject will be merged
\r
202 into the current branch in the submodule.
\r
207 <simpara>The following <emphasis>update</emphasis> procedures are only available via the
\r
208 <emphasis>submodule.<name>.update</emphasis> configuration variable:</simpara>
\r
216 arbitrary shell command that takes a single
\r
217 argument (the sha1 of the commit recorded in the
\r
218 superproject) is executed. When <emphasis>submodule.<name>.update</emphasis>
\r
219 is set to <emphasis>!command</emphasis>, the remainder after the exclamation mark
\r
220 is the custom command.
\r
230 the submodule is not updated.
\r
235 <simpara>If the submodule is not yet initialized, and you just want to use the
\r
236 setting as stored in <emphasis>.gitmodules</emphasis>, you can automatically initialize the
\r
237 submodule with the <emphasis>--init</emphasis> option.</simpara>
\r
238 <simpara>If <emphasis>--recursive</emphasis> is specified, this command will recurse into the
\r
239 registered submodules, and update any nested submodules within.</simpara>
\r
244 set-branch (-b|--branch) <branch> [--] <path>
\r
247 set-branch (-d|--default) [--] <path>
\r
251 Sets the default remote tracking branch for the submodule. The
\r
252 <emphasis>--branch</emphasis> option allows the remote branch to be specified. The
\r
253 <emphasis>--default</emphasis> option removes the submodule.<name>.branch configuration
\r
254 key, which causes the tracking branch to default to the remote <emphasis>HEAD</emphasis>.
\r
260 set-url [--] <path> <newurl>
\r
264 Sets the URL of the specified submodule to <newurl>. Then, it will
\r
265 automatically synchronize the submodule's new remote URL
\r
272 summary [--cached|--files] [(-n|--summary-limit) <n>] [commit] [--] [<path>…]
\r
276 Show commit summary between the given commit (defaults to HEAD) and
\r
277 working tree/index. For a submodule in question, a series of commits
\r
278 in the submodule between the given super project commit and the
\r
279 index or working tree (switched by <emphasis>--cached</emphasis>) are shown. If the option
\r
280 <emphasis>--files</emphasis> is given, show the series of commits in the submodule between
\r
281 the index of the super project and the working tree of the submodule
\r
282 (this option doesn't allow to use the <emphasis>--cached</emphasis> option or to provide an
\r
285 <simpara>Using the <emphasis>--submodule=log</emphasis> option with <xref linkend="git-diff(1)" /> will provide that
\r
286 information too.</simpara>
\r
291 foreach [--recursive] <command>
\r
295 Evaluates an arbitrary shell command in each checked out submodule.
\r
296 The command has access to the variables $name, $sm_path, $displaypath,
\r
297 $sha1 and $toplevel:
\r
298 $name is the name of the relevant submodule section in <emphasis>.gitmodules</emphasis>,
\r
299 $sm_path is the path of the submodule as recorded in the immediate
\r
300 superproject, $displaypath contains the relative path from the
\r
301 current working directory to the submodules root directory,
\r
302 $sha1 is the commit as recorded in the immediate
\r
303 superproject, and $toplevel is the absolute path to the top-level
\r
304 of the immediate superproject.
\r
305 Note that to avoid conflicts with <emphasis>$PATH</emphasis> on Windows, the <emphasis>$path</emphasis>
\r
306 variable is now a deprecated synonym of <emphasis>$sm_path</emphasis> variable.
\r
307 Any submodules defined in the superproject but not checked out are
\r
308 ignored by this command. Unless given <emphasis>--quiet</emphasis>, foreach prints the name
\r
309 of each submodule before evaluating the command.
\r
310 If <emphasis>--recursive</emphasis> is given, submodules are traversed recursively (i.e.
\r
311 the given shell command is evaluated in nested submodules as well).
\r
312 A non-zero return from the command in any submodule causes
\r
313 the processing to terminate. This can be overridden by adding <emphasis>|| :</emphasis>
\r
314 to the end of the command.
\r
316 <simpara>As an example, the command below will show the path and currently
\r
317 checked out commit for each submodule:</simpara>
\r
318 <screen>git submodule foreach 'echo $sm_path `git rev-parse HEAD`'</screen>
\r
323 sync [--recursive] [--] [<path>…]
\r
327 Synchronizes submodules' remote URL configuration setting
\r
328 to the value specified in <emphasis>.gitmodules</emphasis>. It will only affect those
\r
329 submodules which already have a URL entry in .git/config (that is the
\r
330 case when they are initialized or freshly added). This is useful when
\r
331 submodule URLs change upstream and you need to update your local
\r
332 repositories accordingly.
\r
334 <simpara><emphasis>git submodule sync</emphasis> synchronizes all submodules while
\r
335 <emphasis>git submodule sync -- A</emphasis> synchronizes submodule "A" only.</simpara>
\r
336 <simpara>If <emphasis>--recursive</emphasis> is specified, this command will recurse into the
\r
337 registered submodules, and sync any nested submodules within.</simpara>
\r
346 If a git directory of a submodule is inside the submodule,
\r
347 move the git directory of the submodule into its superproject's
\r
348 <emphasis>$GIT_DIR/modules</emphasis> path and then connect the git directory and
\r
349 its working directory by setting the <emphasis>core.worktree</emphasis> and adding
\r
350 a .git file pointing to the git directory embedded in the
\r
351 superprojects git directory.
\r
353 <simpara>A repository that was cloned independently and later added as a submodule or
\r
354 old setups have the submodules git directory inside the submodule instead of
\r
355 embedded into the superprojects git directory.</simpara>
\r
356 <simpara>This command is recursive by default.</simpara>
\r
361 <simplesect id="git-submodule(1)__options">
\r
362 <title>OPTIONS</title>
\r
373 Only print error messages.
\r
383 This option is only valid for add and update commands.
\r
384 Progress status is reported on the standard error stream
\r
385 by default when it is attached to a terminal, unless -q
\r
386 is specified. This flag forces progress status even if the
\r
387 standard error stream is not directed to a terminal.
\r
397 This option is only valid for the deinit command. Unregister all
\r
398 submodules in the working tree.
\r
407 --branch <branch>
\r
411 Branch of repository to add as submodule.
\r
412 The name of the branch is recorded as <emphasis>submodule.<name>.branch</emphasis> in
\r
413 <emphasis>.gitmodules</emphasis> for <emphasis>update --remote</emphasis>. A special value of <emphasis>.</emphasis> is used to
\r
414 indicate that the name of the branch in the submodule should be the
\r
415 same name as the current branch in the current repository. If the
\r
416 option is not specified, it defaults to the remote <emphasis>HEAD</emphasis>.
\r
429 This option is only valid for add, deinit and update commands.
\r
430 When running add, allow adding an otherwise ignored submodule path.
\r
431 When running deinit the submodule working trees will be removed even
\r
432 if they contain local changes.
\r
433 When running update (only effective with the checkout procedure),
\r
434 throw away local changes in submodules when switching to a
\r
435 different commit; and always run a checkout operation in the
\r
436 submodule, even if the commit listed in the index of the
\r
437 containing repository matches the commit checked out in the
\r
448 This option is only valid for status and summary commands. These
\r
449 commands typically use the commit found in the submodule HEAD, but
\r
450 with this option, the commit stored in the index is used instead.
\r
460 This option is only valid for the summary command. This command
\r
461 compares the commit in the index with that in the submodule HEAD
\r
462 when this option is used.
\r
475 This option is only valid for the summary command.
\r
476 Limit the summary size (number of commits shown in total).
\r
477 Giving 0 will disable the summary; a negative number means unlimited
\r
478 (the default). This limit only applies to modified submodules. The
\r
479 size is always limited to 1 for added/deleted/typechanged submodules.
\r
489 This option is only valid for the update command. Instead of using
\r
490 the superproject's recorded SHA-1 to update the submodule, use the
\r
491 status of the submodule's remote-tracking branch. The remote used
\r
492 is branch's remote (<emphasis>branch.<name>.remote</emphasis>), defaulting to <emphasis>origin</emphasis>.
\r
493 The remote branch used defaults to the remote <emphasis>HEAD</emphasis>, but the branch
\r
494 name may be overridden by setting the <emphasis>submodule.<name>.branch</emphasis>
\r
495 option in either <emphasis>.gitmodules</emphasis> or <emphasis>.git/config</emphasis> (with <emphasis>.git/config</emphasis>
\r
496 taking precedence).
\r
498 <simpara>This works for any of the supported update procedures (<emphasis>--checkout</emphasis>,
\r
499 <emphasis>--rebase</emphasis>, etc.). The only change is the source of the target SHA-1.
\r
500 For example, <emphasis>submodule update --remote --merge</emphasis> will merge upstream
\r
501 submodule changes into the submodules, while <emphasis>submodule update
\r
502 --merge</emphasis> will merge superproject gitlink changes into the submodules.</simpara>
\r
503 <simpara>In order to ensure a current tracking branch state, <emphasis>update --remote</emphasis>
\r
504 fetches the submodule's remote repository before calculating the
\r
505 SHA-1. If you don't want to fetch, you should use <emphasis>submodule update
\r
506 --remote --no-fetch</emphasis>.</simpara>
\r
507 <simpara>Use this option to integrate changes from the upstream subproject with
\r
508 your submodule's current HEAD. Alternatively, you can run <emphasis>git pull</emphasis>
\r
509 from the submodule, which is equivalent except for the remote branch
\r
510 name: <emphasis>update --remote</emphasis> uses the default upstream repository and
\r
511 <emphasis>submodule.<name>.branch</emphasis>, while <emphasis>git pull</emphasis> uses the submodule's
\r
512 <emphasis>branch.<name>.merge</emphasis>. Prefer <emphasis>submodule.<name>.branch</emphasis> if you want
\r
513 to distribute the default upstream branch with the superproject and
\r
514 <emphasis>branch.<name>.merge</emphasis> if you want a more native feel while working in
\r
515 the submodule itself.</simpara>
\r
527 This option is only valid for the update command.
\r
528 Don't fetch new objects from the remote site.
\r
538 This option is only valid for the update command.
\r
539 Checkout the commit recorded in the superproject on a detached HEAD
\r
540 in the submodule. This is the default behavior, the main use of
\r
541 this option is to override <emphasis>submodule.$name.update</emphasis> when set to
\r
542 a value other than <emphasis>checkout</emphasis>.
\r
543 If the key <emphasis>submodule.$name.update</emphasis> is either not explicitly set or
\r
544 set to <emphasis>checkout</emphasis>, this option is implicit.
\r
554 This option is only valid for the update command.
\r
555 Merge the commit recorded in the superproject into the current branch
\r
556 of the submodule. If this option is given, the submodule's HEAD will
\r
557 not be detached. If a merge failure prevents this process, you will
\r
558 have to resolve the resulting conflicts within the submodule with the
\r
559 usual conflict resolution tools.
\r
560 If the key <emphasis>submodule.$name.update</emphasis> is set to <emphasis>merge</emphasis>, this option is
\r
571 This option is only valid for the update command.
\r
572 Rebase the current branch onto the commit recorded in the
\r
573 superproject. If this option is given, the submodule's HEAD will not
\r
574 be detached. If a merge failure prevents this process, you will have
\r
575 to resolve these failures with <xref linkend="git-rebase(1)" />.
\r
576 If the key <emphasis>submodule.$name.update</emphasis> is set to <emphasis>rebase</emphasis>, this option is
\r
587 This option is only valid for the update command.
\r
588 Initialize all submodules for which "git submodule init" has not been
\r
589 called so far before updating.
\r
599 This option is only valid for the add command. It sets the submodule's
\r
600 name to the given string instead of defaulting to its path. The name
\r
601 must be valid as a directory name and may not end with a <emphasis>/</emphasis>.
\r
607 --reference <repository>
\r
611 This option is only valid for add and update commands. These
\r
612 commands sometimes need to clone a remote repository. In this case,
\r
613 this option will be passed to the <xref linkend="git-clone(1)" /> command.
\r
615 <simpara><emphasis role="strong">NOTE</emphasis>: Do <emphasis role="strong">not</emphasis> use this option unless you have read the note
\r
616 for <xref linkend="git-clone(1)" />'s <emphasis>--reference</emphasis>, <emphasis>--shared</emphasis>, and <emphasis>--dissociate</emphasis>
\r
617 options carefully.</simpara>
\r
626 This option is only valid for add and update commands. These
\r
627 commands sometimes need to clone a remote repository. In this case,
\r
628 this option will be passed to the <xref linkend="git-clone(1)" /> command.
\r
630 <simpara><emphasis role="strong">NOTE</emphasis>: see the NOTE for the <emphasis>--reference</emphasis> option.</simpara>
\r
639 This option is only valid for foreach, update, status and sync commands.
\r
640 Traverse submodules recursively. The operation is performed not
\r
641 only in the submodules of the current repo, but also
\r
642 in any nested submodules inside those submodules (and so on).
\r
652 This option is valid for add and update commands. Create a <emphasis>shallow</emphasis>
\r
653 clone with a history truncated to the specified number of revisions.
\r
654 See <xref linkend="git-clone(1)" />
\r
660 --[no-]recommend-shallow
\r
664 This option is only valid for the update command.
\r
665 The initial clone of a submodule will use the recommended
\r
666 <emphasis>submodule.<name>.shallow</emphasis> as provided by the <emphasis>.gitmodules</emphasis> file
\r
667 by default. To ignore the suggestions use <emphasis>--no-recommend-shallow</emphasis>.
\r
680 This option is only valid for the update command.
\r
681 Clone new submodules in parallel with as many jobs.
\r
682 Defaults to the <emphasis>submodule.fetchJobs</emphasis> option.
\r
688 --[no-]single-branch
\r
692 This option is only valid for the update command.
\r
693 Clone only one branch during update: HEAD or one specified by --branch.
\r
699 <path>…
\r
703 Paths to submodule(s). When specified this will restrict the command
\r
704 to only operate on the submodules found at the specified paths.
\r
705 (This argument is required with add).
\r
711 <simplesect id="git-submodule(1)__files">
\r
712 <title>FILES</title>
\r
713 <simpara>When initializing submodules, a <emphasis>.gitmodules</emphasis> file in the top-level directory
\r
714 of the containing repository is used to find the url of each submodule.
\r
715 This file should be formatted in the same way as <emphasis>$GIT_DIR/config</emphasis>. The key
\r
716 to each submodule url is "submodule.$name.url". See <xref linkend="gitmodules(5)" />
\r
717 for details.</simpara>
\r
719 <simplesect id="git-submodule(1)__see_also">
\r
720 <title>SEE ALSO</title>
\r
721 <simpara><xref linkend="gitsubmodules(7)" />, <xref linkend="gitmodules(5)" />.</simpara>
\r
723 <simplesect id="git-submodule(1)__git">
\r
725 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r