Autogenerated HTML docs for v1.7.5.2-315-g11bc3
[git/jnareb-git.git] / git-submodule.html
blob8b114b56bad82d114fe26314c126706447a9b913
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.4.5" />
7 <title>git-submodule(1)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
245 list-style-type: upper-roman;
248 div.compact ul, div.compact ol,
249 div.compact p, div.compact p,
250 div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
275 div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
279 div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 git-submodule(1) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>git-submodule -
411 Initialize, update or inspect submodules
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="verseblock">
418 <div class="verseblock-content"><em>git submodule</em> [--quiet] add [-b branch] [-f|--force]
419 [--reference &lt;repository&gt;] [--] &lt;repository&gt; [&lt;path&gt;]
420 <em>git submodule</em> [--quiet] status [--cached] [--recursive] [--] [&lt;path&gt;&#8230;]
421 <em>git submodule</em> [--quiet] init [--] [&lt;path&gt;&#8230;]
422 <em>git submodule</em> [--quiet] update [--init] [-N|--no-fetch] [--rebase]
423 [--reference &lt;repository&gt;] [--merge] [--recursive] [--] [&lt;path&gt;&#8230;]
424 <em>git submodule</em> [--quiet] summary [--cached|--files] [--summary-limit &lt;n&gt;] [commit] [--] [&lt;path&gt;&#8230;]
425 <em>git submodule</em> [--quiet] foreach [--recursive] &lt;command&gt;
426 <em>git submodule</em> [--quiet] sync [--] [&lt;path&gt;&#8230;]</div>
427 <div class="verseblock-attribution">
428 </div></div>
429 </div>
430 <h2 id="_description">DESCRIPTION</h2>
431 <div class="sectionbody">
432 <div class="paragraph"><p>Submodules allow foreign repositories to be embedded within
433 a dedicated subdirectory of the source tree, always pointed
434 at a particular commit.</p></div>
435 <div class="paragraph"><p>They are not to be confused with remotes, which are meant mainly
436 for branches of the same project; submodules are meant for
437 different projects you would like to make part of your source tree,
438 while the history of the two projects still stays completely
439 independent and you cannot modify the contents of the submodule
440 from within the main project.
441 If you want to merge the project histories and want to treat the
442 aggregated whole as a single project from then on, you may want to
443 add a remote for the other project and use the <em>subtree</em> merge strategy,
444 instead of treating the other project as a submodule. Directories
445 that come from both projects can be cloned and checked out as a whole
446 if you choose to go that route.</p></div>
447 <div class="paragraph"><p>Submodules are composed from a so-called <tt>gitlink</tt> tree entry
448 in the main repository that refers to a particular commit object
449 within the inner repository that is completely separate.
450 A record in the <tt>.gitmodules</tt> file at the root of the source
451 tree assigns a logical name to the submodule and describes
452 the default URL the submodule shall be cloned from.
453 The logical name can be used for overriding this URL within your
454 local repository configuration (see <em>submodule init</em>).</p></div>
455 <div class="paragraph"><p>This command will manage the tree entries and contents of the
456 gitmodules file for you, as well as inspect the status of your
457 submodules and update them.
458 When adding a new submodule to the tree, the <em>add</em> subcommand
459 is to be used. However, when pulling a tree containing submodules,
460 these will not be checked out by default;
461 the <em>init</em> and <em>update</em> subcommands will maintain submodules
462 checked out and at appropriate revision in your working tree.
463 You can briefly inspect the up-to-date status of your submodules
464 using the <em>status</em> subcommand and get a detailed overview of the
465 difference between the index and checkouts using the <em>summary</em>
466 subcommand.</p></div>
467 </div>
468 <h2 id="_commands">COMMANDS</h2>
469 <div class="sectionbody">
470 <div class="dlist"><dl>
471 <dt class="hdlist1">
473 </dt>
474 <dd>
476 Add the given repository as a submodule at the given path
477 to the changeset to be committed next to the current
478 project: the current project is termed the "superproject".
479 </p>
480 <div class="paragraph"><p>This requires at least one argument: &lt;repository&gt;. The optional
481 argument &lt;path&gt; is the relative location for the cloned submodule
482 to exist in the superproject. If &lt;path&gt; is not given, the
483 "humanish" part of the source repository is used ("repo" for
484 "/path/to/repo.git" and "foo" for "host.xz:foo/.git").</p></div>
485 <div class="paragraph"><p>&lt;repository&gt; is the URL of the new submodule&#8217;s origin repository.
486 This may be either an absolute URL, or (if it begins with ./
487 or ../), the location relative to the superproject&#8217;s origin
488 repository.</p></div>
489 <div class="paragraph"><p>&lt;path&gt; is the relative location for the cloned submodule to
490 exist in the superproject. If &lt;path&gt; does not exist, then the
491 submodule is created by cloning from the named URL. If &lt;path&gt; does
492 exist and is already a valid git repository, then this is added
493 to the changeset without cloning. This second form is provided
494 to ease creating a new submodule from scratch, and presumes
495 the user will later push the submodule to the given URL.</p></div>
496 <div class="paragraph"><p>In either case, the given URL is recorded into .gitmodules for
497 use by subsequent users cloning the superproject. If the URL is
498 given relative to the superproject&#8217;s repository, the presumption
499 is the superproject and submodule repositories will be kept
500 together in the same relative location, and only the
501 superproject&#8217;s URL needs to be provided: git-submodule will correctly
502 locate the submodule using the relative URL in .gitmodules.</p></div>
503 </dd>
504 <dt class="hdlist1">
505 status
506 </dt>
507 <dd>
509 Show the status of the submodules. This will print the SHA-1 of the
510 currently checked out commit for each submodule, along with the
511 submodule path and the output of <em>git describe</em> for the
512 SHA-1. Each SHA-1 will be prefixed with <tt>-</tt> if the submodule is not
513 initialized, <tt>+</tt> if the currently checked out submodule commit
514 does not match the SHA-1 found in the index of the containing
515 repository and <tt>U</tt> if the submodule has merge conflicts.
516 This command is the default command for <em>git submodule</em>.
517 </p>
518 <div class="paragraph"><p>If <em>--recursive</em> is specified, this command will recurse into nested
519 submodules, and show their status as well.</p></div>
520 </dd>
521 <dt class="hdlist1">
522 init
523 </dt>
524 <dd>
526 Initialize the submodules, i.e. register each submodule name
527 and url found in .gitmodules into .git/config.
528 The key used in .git/config is <tt>submodule.$name.url</tt>.
529 This command does not alter existing information in .git/config.
530 You can then customize the submodule clone URLs in .git/config
531 for your local setup and proceed to <tt>git submodule update</tt>;
532 you can also just use <tt>git submodule update --init</tt> without
533 the explicit <em>init</em> step if you do not intend to customize
534 any submodule locations.
535 </p>
536 </dd>
537 <dt class="hdlist1">
538 update
539 </dt>
540 <dd>
542 Update the registered submodules, i.e. clone missing submodules and
543 checkout the commit specified in the index of the containing repository.
544 This will make the submodules HEAD be detached unless <em>--rebase</em> or
545 <em>--merge</em> is specified or the key <tt>submodule.$name.update</tt> is set to
546 <tt>rebase</tt> or <tt>merge</tt>.
547 </p>
548 <div class="paragraph"><p>If the submodule is not yet initialized, and you just want to use the
549 setting as stored in .gitmodules, you can automatically initialize the
550 submodule with the --init option.</p></div>
551 <div class="paragraph"><p>If <em>--recursive</em> is specified, this command will recurse into the
552 registered submodules, and update any nested submodules within.</p></div>
553 </dd>
554 <dt class="hdlist1">
555 summary
556 </dt>
557 <dd>
559 Show commit summary between the given commit (defaults to HEAD) and
560 working tree/index. For a submodule in question, a series of commits
561 in the submodule between the given super project commit and the
562 index or working tree (switched by --cached) are shown. If the option
563 --files is given, show the series of commits in the submodule between
564 the index of the super project and the working tree of the submodule
565 (this option doesn&#8217;t allow to use the --cached option or to provide an
566 explicit commit).
567 </p>
568 </dd>
569 <dt class="hdlist1">
570 foreach
571 </dt>
572 <dd>
574 Evaluates an arbitrary shell command in each checked out submodule.
575 The command has access to the variables $name, $path, $sha1 and
576 $toplevel:
577 $name is the name of the relevant submodule section in .gitmodules,
578 $path is the name of the submodule directory relative to the
579 superproject, $sha1 is the commit as recorded in the superproject,
580 and $toplevel is the absolute path to the top-level of the superproject.
581 Any submodules defined in the superproject but not checked out are
582 ignored by this command. Unless given --quiet, foreach prints the name
583 of each submodule before evaluating the command.
584 If --recursive is given, submodules are traversed recursively (i.e.
585 the given shell command is evaluated in nested submodules as well).
586 A non-zero return from the command in any submodule causes
587 the processing to terminate. This can be overridden by adding <em>|| :</em>
588 to the end of the command.
589 </p>
590 <div class="paragraph"><p>As an example, <tt>git submodule foreach 'echo $path &#96;git
591 rev-parse HEAD&#96;'</tt> will show the path and currently checked out
592 commit for each submodule.</p></div>
593 </dd>
594 <dt class="hdlist1">
595 sync
596 </dt>
597 <dd>
599 Synchronizes submodules' remote URL configuration setting
600 to the value specified in .gitmodules. This is useful when
601 submodule URLs change upstream and you need to update your local
602 repositories accordingly.
603 </p>
604 <div class="paragraph"><p>"git submodule sync" synchronizes all submodules while
605 "git submodule sync&#8201;&#8212;&#8201;A" synchronizes submodule "A" only.</p></div>
606 </dd>
607 </dl></div>
608 </div>
609 <h2 id="_options">OPTIONS</h2>
610 <div class="sectionbody">
611 <div class="dlist"><dl>
612 <dt class="hdlist1">
614 </dt>
615 <dt class="hdlist1">
616 --quiet
617 </dt>
618 <dd>
620 Only print error messages.
621 </p>
622 </dd>
623 <dt class="hdlist1">
625 </dt>
626 <dt class="hdlist1">
627 --branch
628 </dt>
629 <dd>
631 Branch of repository to add as submodule.
632 </p>
633 </dd>
634 <dt class="hdlist1">
636 </dt>
637 <dt class="hdlist1">
638 --force
639 </dt>
640 <dd>
642 This option is only valid for add and update commands.
643 When running add, allow adding an otherwise ignored submodule path.
644 When running update, throw away local changes in submodules when
645 switching to a different commit.
646 </p>
647 </dd>
648 <dt class="hdlist1">
649 --cached
650 </dt>
651 <dd>
653 This option is only valid for status and summary commands. These
654 commands typically use the commit found in the submodule HEAD, but
655 with this option, the commit stored in the index is used instead.
656 </p>
657 </dd>
658 <dt class="hdlist1">
659 --files
660 </dt>
661 <dd>
663 This option is only valid for the summary command. This command
664 compares the commit in the index with that in the submodule HEAD
665 when this option is used.
666 </p>
667 </dd>
668 <dt class="hdlist1">
670 </dt>
671 <dt class="hdlist1">
672 --summary-limit
673 </dt>
674 <dd>
676 This option is only valid for the summary command.
677 Limit the summary size (number of commits shown in total).
678 Giving 0 will disable the summary; a negative number means unlimited
679 (the default). This limit only applies to modified submodules. The
680 size is always limited to 1 for added/deleted/typechanged submodules.
681 </p>
682 </dd>
683 <dt class="hdlist1">
685 </dt>
686 <dt class="hdlist1">
687 --no-fetch
688 </dt>
689 <dd>
691 This option is only valid for the update command.
692 Don&#8217;t fetch new objects from the remote site.
693 </p>
694 </dd>
695 <dt class="hdlist1">
696 --merge
697 </dt>
698 <dd>
700 This option is only valid for the update command.
701 Merge the commit recorded in the superproject into the current branch
702 of the submodule. If this option is given, the submodule&#8217;s HEAD will
703 not be detached. If a merge failure prevents this process, you will
704 have to resolve the resulting conflicts within the submodule with the
705 usual conflict resolution tools.
706 If the key <tt>submodule.$name.update</tt> is set to <tt>merge</tt>, this option is
707 implicit.
708 </p>
709 </dd>
710 <dt class="hdlist1">
711 --rebase
712 </dt>
713 <dd>
715 This option is only valid for the update command.
716 Rebase the current branch onto the commit recorded in the
717 superproject. If this option is given, the submodule&#8217;s HEAD will not
718 be detached. If a merge failure prevents this process, you will have
719 to resolve these failures with <a href="git-rebase.html">git-rebase(1)</a>.
720 If the key <tt>submodule.$name.update</tt> is set to <tt>rebase</tt>, this option is
721 implicit.
722 </p>
723 </dd>
724 <dt class="hdlist1">
725 --reference &lt;repository&gt;
726 </dt>
727 <dd>
729 This option is only valid for add and update commands. These
730 commands sometimes need to clone a remote repository. In this case,
731 this option will be passed to the <a href="git-clone.html">git-clone(1)</a> command.
732 </p>
733 <div class="paragraph"><p><strong>NOTE</strong>: Do <strong>not</strong> use this option unless you have read the note
734 for <a href="git-clone.html">git-clone(1)</a>'s --reference and --shared options carefully.</p></div>
735 </dd>
736 <dt class="hdlist1">
737 --recursive
738 </dt>
739 <dd>
741 This option is only valid for foreach, update and status commands.
742 Traverse submodules recursively. The operation is performed not
743 only in the submodules of the current repo, but also
744 in any nested submodules inside those submodules (and so on).
745 </p>
746 </dd>
747 <dt class="hdlist1">
748 &lt;path&gt;&#8230;
749 </dt>
750 <dd>
752 Paths to submodule(s). When specified this will restrict the command
753 to only operate on the submodules found at the specified paths.
754 (This argument is required with add).
755 </p>
756 </dd>
757 </dl></div>
758 </div>
759 <h2 id="_files">FILES</h2>
760 <div class="sectionbody">
761 <div class="paragraph"><p>When initializing submodules, a .gitmodules file in the top-level directory
762 of the containing repository is used to find the url of each submodule.
763 This file should be formatted in the same way as <tt>$GIT_DIR/config</tt>. The key
764 to each submodule url is "submodule.$name.url". See <a href="gitmodules.html">gitmodules(5)</a>
765 for details.</p></div>
766 </div>
767 <h2 id="_git">GIT</h2>
768 <div class="sectionbody">
769 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
770 </div>
771 <div id="footer">
772 <div id="footer-text">
773 Last updated 2011-05-03 00:48:04 UTC
774 </div>
775 </div>
776 </body>
777 </html>