1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.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] add [-b <branch>] [-f|--force] [--name <name>]
\r
17 [--reference <repository>] [--] <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] update [--init] [-N|--no-fetch] [--rebase]
\r
21 [--reference <repository>] [--merge] [--recursive] [--] [<path>…]
\r
22 <emphasis>git submodule</emphasis> [--quiet] summary [--cached|--files] [(-n|--summary-limit) <n>]
\r
23 [commit] [--] [<path>…]
\r
24 <emphasis>git submodule</emphasis> [--quiet] foreach [--recursive] <command>
\r
25 <emphasis>git submodule</emphasis> [--quiet] sync [--] [<path>…]</literallayout>
\r
28 <simplesect id="git-submodule(1)__description">
\r
29 <title>DESCRIPTION</title>
\r
30 <simpara>Submodules allow foreign repositories to be embedded within
\r
31 a dedicated subdirectory of the source tree, always pointed
\r
32 at a particular commit.</simpara>
\r
33 <simpara>They are not to be confused with remotes, which are meant mainly
\r
34 for branches of the same project; submodules are meant for
\r
35 different projects you would like to make part of your source tree,
\r
36 while the history of the two projects still stays completely
\r
37 independent and you cannot modify the contents of the submodule
\r
38 from within the main project.
\r
39 If you want to merge the project histories and want to treat the
\r
40 aggregated whole as a single project from then on, you may want to
\r
41 add a remote for the other project and use the <emphasis>subtree</emphasis> merge strategy,
\r
42 instead of treating the other project as a submodule. Directories
\r
43 that come from both projects can be cloned and checked out as a whole
\r
44 if you choose to go that route.</simpara>
\r
45 <simpara>Submodules are composed from a so-called <emphasis>gitlink</emphasis> tree entry
\r
46 in the main repository that refers to a particular commit object
\r
47 within the inner repository that is completely separate.
\r
48 A record in the <emphasis>.gitmodules</emphasis> (see <xref linkend="gitmodules(5)" />) file at the
\r
49 root of the source tree assigns a logical name to the submodule and
\r
50 describes the default URL the submodule shall be cloned from.
\r
51 The logical name can be used for overriding this URL within your
\r
52 local repository configuration (see <emphasis>submodule init</emphasis>).</simpara>
\r
53 <simpara>This command will manage the tree entries and contents of the
\r
54 gitmodules file for you, as well as inspect the status of your
\r
55 submodules and update them.
\r
56 When adding a new submodule to the tree, the <emphasis>add</emphasis> subcommand
\r
57 is to be used. However, when pulling a tree containing submodules,
\r
58 these will not be checked out by default;
\r
59 the <emphasis>init</emphasis> and <emphasis>update</emphasis> subcommands will maintain submodules
\r
60 checked out and at appropriate revision in your working tree.
\r
61 You can briefly inspect the up-to-date status of your submodules
\r
62 using the <emphasis>status</emphasis> subcommand and get a detailed overview of the
\r
63 difference between the index and checkouts using the <emphasis>summary</emphasis>
\r
64 subcommand.</simpara>
\r
66 <simplesect id="git-submodule(1)__commands">
\r
67 <title>COMMANDS</title>
\r
75 Add the given repository as a submodule at the given path
\r
76 to the changeset to be committed next to the current
\r
77 project: the current project is termed the "superproject".
\r
79 <simpara>This requires at least one argument: <repository>. The optional
\r
80 argument <path> is the relative location for the cloned submodule
\r
81 to exist in the superproject. If <path> is not given, the
\r
82 "humanish" part of the source repository is used ("repo" for
\r
83 "/path/to/repo.git" and "foo" for "host.xz:foo/.git").</simpara>
\r
84 <simpara><repository> is the URL of the new submodule's origin repository.
\r
85 This may be either an absolute URL, or (if it begins with ./
\r
86 or ../), the location relative to the superproject's origin
\r
87 repository (Please note that to specify a repository <emphasis>foo.git</emphasis>
\r
88 which is located right next to a superproject <emphasis>bar.git</emphasis>, you'll
\r
89 have to use <emphasis>../foo.git</emphasis> instead of <emphasis>./foo.git</emphasis> - as one might expect
\r
90 when following the rules for relative URLs - because the evaluation
\r
91 of relative URLs in Git is identical to that of relative directories).
\r
92 If the superproject doesn't have an origin configured
\r
93 the superproject is its own authoritative upstream and the current
\r
94 working directory is used instead.</simpara>
\r
95 <simpara><path> is the relative location for the cloned submodule to
\r
96 exist in the superproject. If <path> does not exist, then the
\r
97 submodule is created by cloning from the named URL. If <path> does
\r
98 exist and is already a valid git repository, then this is added
\r
99 to the changeset without cloning. This second form is provided
\r
100 to ease creating a new submodule from scratch, and presumes
\r
101 the user will later push the submodule to the given URL.</simpara>
\r
102 <simpara>In either case, the given URL is recorded into .gitmodules for
\r
103 use by subsequent users cloning the superproject. If the URL is
\r
104 given relative to the superproject's repository, the presumption
\r
105 is the superproject and submodule repositories will be kept
\r
106 together in the same relative location, and only the
\r
107 superproject's URL needs to be provided: git-submodule will correctly
\r
108 locate the submodule using the relative URL in .gitmodules.</simpara>
\r
117 Show the status of the submodules. This will print the SHA-1 of the
\r
118 currently checked out commit for each submodule, along with the
\r
119 submodule path and the output of <emphasis>git describe</emphasis> for the
\r
120 SHA-1. Each SHA-1 will be prefixed with <emphasis>-</emphasis> if the submodule is not
\r
121 initialized, <emphasis>+</emphasis> if the currently checked out submodule commit
\r
122 does not match the SHA-1 found in the index of the containing
\r
123 repository and <emphasis>U</emphasis> if the submodule has merge conflicts.
\r
125 <simpara>If <emphasis>--recursive</emphasis> is specified, this command will recurse into nested
\r
126 submodules, and show their status as well.</simpara>
\r
127 <simpara>If you are only interested in changes of the currently initialized
\r
128 submodules with respect to the commit recorded in the index or the HEAD,
\r
129 <xref linkend="git-status(1)" /> and <xref linkend="git-diff(1)" /> will provide that information
\r
130 too (and can also report changes to a submodule's work tree).</simpara>
\r
139 Initialize the submodules, i.e. register each submodule name
\r
140 and url found in .gitmodules into .git/config.
\r
141 It will also copy the value of <emphasis>submodule.$name.update</emphasis> into
\r
143 The key used in .git/config is <emphasis>submodule.$name.url</emphasis>.
\r
144 This command does not alter existing information in .git/config.
\r
145 You can then customize the submodule clone URLs in .git/config
\r
146 for your local setup and proceed to <emphasis>git submodule update</emphasis>;
\r
147 you can also just use <emphasis>git submodule update --init</emphasis> without
\r
148 the explicit <emphasis>init</emphasis> step if you do not intend to customize
\r
149 any submodule locations.
\r
159 Update the registered submodules, i.e. clone missing submodules and
\r
160 checkout the commit specified in the index of the containing repository.
\r
161 This will make the submodules HEAD be detached unless <emphasis>--rebase</emphasis> or
\r
162 <emphasis>--merge</emphasis> is specified or the key <emphasis>submodule.$name.update</emphasis> is set to
\r
163 <emphasis>rebase</emphasis>, <emphasis>merge</emphasis> or <emphasis>none</emphasis>. <emphasis>none</emphasis> can be overridden by specifying
\r
164 <emphasis>--checkout</emphasis>.
\r
166 <simpara>If the submodule is not yet initialized, and you just want to use the
\r
167 setting as stored in .gitmodules, you can automatically initialize the
\r
168 submodule with the <emphasis>--init</emphasis> option.</simpara>
\r
169 <simpara>If <emphasis>--recursive</emphasis> is specified, this command will recurse into the
\r
170 registered submodules, and update any nested submodules within.</simpara>
\r
171 <simpara>If <emphasis>--force</emphasis> is specified, the submodule will be checked out (using
\r
172 <emphasis>git checkout --force</emphasis> if appropriate), even if the commit specified in the
\r
173 index of the containing repository already matches the commit checked out in
\r
174 the submodule.</simpara>
\r
183 Show commit summary between the given commit (defaults to HEAD) and
\r
184 working tree/index. For a submodule in question, a series of commits
\r
185 in the submodule between the given super project commit and the
\r
186 index or working tree (switched by <emphasis>--cached</emphasis>) are shown. If the option
\r
187 <emphasis>--files</emphasis> is given, show the series of commits in the submodule between
\r
188 the index of the super project and the working tree of the submodule
\r
189 (this option doesn't allow to use the <emphasis>--cached</emphasis> option or to provide an
\r
192 <simpara>Using the <emphasis>--submodule=log</emphasis> option with <xref linkend="git-diff(1)" /> will provide that
\r
193 information too.</simpara>
\r
202 Evaluates an arbitrary shell command in each checked out submodule.
\r
203 The command has access to the variables $name, $path, $sha1 and
\r
205 $name is the name of the relevant submodule section in .gitmodules,
\r
206 $path is the name of the submodule directory relative to the
\r
207 superproject, $sha1 is the commit as recorded in the superproject,
\r
208 and $toplevel is the absolute path to the top-level of the superproject.
\r
209 Any submodules defined in the superproject but not checked out are
\r
210 ignored by this command. Unless given <emphasis>--quiet</emphasis>, foreach prints the name
\r
211 of each submodule before evaluating the command.
\r
212 If <emphasis>--recursive</emphasis> is given, submodules are traversed recursively (i.e.
\r
213 the given shell command is evaluated in nested submodules as well).
\r
214 A non-zero return from the command in any submodule causes
\r
215 the processing to terminate. This can be overridden by adding <emphasis>|| :</emphasis>
\r
216 to the end of the command.
\r
218 <simpara>As an example, <literal>git submodule foreach 'echo $path `git
\r
219 rev-parse HEAD`'</literal> will show the path and currently checked out
\r
220 commit for each submodule.</simpara>
\r
229 Synchronizes submodules' remote URL configuration setting
\r
230 to the value specified in .gitmodules. It will only affect those
\r
231 submodules which already have a URL entry in .git/config (that is the
\r
232 case when they are initialized or freshly added). This is useful when
\r
233 submodule URLs change upstream and you need to update your local
\r
234 repositories accordingly.
\r
236 <simpara>"git submodule sync" synchronizes all submodules while
\r
237 "git submodule sync -- A" synchronizes submodule "A" only.</simpara>
\r
242 <simplesect id="git-submodule(1)__options">
\r
243 <title>OPTIONS</title>
\r
254 Only print error messages.
\r
267 Branch of repository to add as submodule.
\r
280 This option is only valid for add and update commands.
\r
281 When running add, allow adding an otherwise ignored submodule path.
\r
282 When running update, throw away local changes in submodules when
\r
283 switching to a different commit; and always run a checkout operation
\r
284 in the submodule, even if the commit listed in the index of the
\r
285 containing repository matches the commit checked out in the submodule.
\r
295 This option is only valid for status and summary commands. These
\r
296 commands typically use the commit found in the submodule HEAD, but
\r
297 with this option, the commit stored in the index is used instead.
\r
307 This option is only valid for the summary command. This command
\r
308 compares the commit in the index with that in the submodule HEAD
\r
309 when this option is used.
\r
322 This option is only valid for the summary command.
\r
323 Limit the summary size (number of commits shown in total).
\r
324 Giving 0 will disable the summary; a negative number means unlimited
\r
325 (the default). This limit only applies to modified submodules. The
\r
326 size is always limited to 1 for added/deleted/typechanged submodules.
\r
339 This option is only valid for the update command.
\r
340 Don't fetch new objects from the remote site.
\r
350 This option is only valid for the update command.
\r
351 Merge the commit recorded in the superproject into the current branch
\r
352 of the submodule. If this option is given, the submodule's HEAD will
\r
353 not be detached. If a merge failure prevents this process, you will
\r
354 have to resolve the resulting conflicts within the submodule with the
\r
355 usual conflict resolution tools.
\r
356 If the key <emphasis>submodule.$name.update</emphasis> is set to <emphasis>merge</emphasis>, this option is
\r
367 This option is only valid for the update command.
\r
368 Rebase the current branch onto the commit recorded in the
\r
369 superproject. If this option is given, the submodule's HEAD will not
\r
370 be detached. If a merge failure prevents this process, you will have
\r
371 to resolve these failures with <xref linkend="git-rebase(1)" />.
\r
372 If the key <emphasis>submodule.$name.update</emphasis> is set to <emphasis>rebase</emphasis>, this option is
\r
383 This option is only valid for the update command.
\r
384 Initialize all submodules for which "git submodule init" has not been
\r
385 called so far before updating.
\r
395 This option is only valid for the add command. It sets the submodule's
\r
396 name to the given string instead of defaulting to its path. The name
\r
397 must be valid as a directory name and may not end with a <emphasis>/</emphasis>.
\r
403 --reference <repository>
\r
407 This option is only valid for add and update commands. These
\r
408 commands sometimes need to clone a remote repository. In this case,
\r
409 this option will be passed to the <xref linkend="git-clone(1)" /> command.
\r
411 <simpara><emphasis role="strong">NOTE</emphasis>: Do <emphasis role="strong">not</emphasis> use this option unless you have read the note
\r
412 for <xref linkend="git-clone(1)" />'s <emphasis>--reference</emphasis> and <emphasis>--shared</emphasis> options carefully.</simpara>
\r
421 This option is only valid for foreach, update and status commands.
\r
422 Traverse submodules recursively. The operation is performed not
\r
423 only in the submodules of the current repo, but also
\r
424 in any nested submodules inside those submodules (and so on).
\r
430 <path>…
\r
434 Paths to submodule(s). When specified this will restrict the command
\r
435 to only operate on the submodules found at the specified paths.
\r
436 (This argument is required with add).
\r
442 <simplesect id="git-submodule(1)__files">
\r
443 <title>FILES</title>
\r
444 <simpara>When initializing submodules, a .gitmodules file in the top-level directory
\r
445 of the containing repository is used to find the url of each submodule.
\r
446 This file should be formatted in the same way as <emphasis>$GIT_DIR/config</emphasis>. The key
\r
447 to each submodule url is "submodule.$name.url". See <xref linkend="gitmodules(5)" />
\r
448 for details.</simpara>
\r
450 <simplesect id="git-submodule(1)__git">
\r
452 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r