Autogenerated HTML docs for v1.7.6-396-ge0613
[git/jnareb-git.git] / git-submodule.html
blob24bf5fd2534e610c31439523866108ae7e48f8b1
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. If the superproject doesn&#8217;t have an origin configured
489 the superproject is its own authoritative upstream and the current
490 working directory is used instead.</p></div>
491 <div class="paragraph"><p>&lt;path&gt; is the relative location for the cloned submodule to
492 exist in the superproject. If &lt;path&gt; does not exist, then the
493 submodule is created by cloning from the named URL. If &lt;path&gt; does
494 exist and is already a valid git repository, then this is added
495 to the changeset without cloning. This second form is provided
496 to ease creating a new submodule from scratch, and presumes
497 the user will later push the submodule to the given URL.</p></div>
498 <div class="paragraph"><p>In either case, the given URL is recorded into .gitmodules for
499 use by subsequent users cloning the superproject. If the URL is
500 given relative to the superproject&#8217;s repository, the presumption
501 is the superproject and submodule repositories will be kept
502 together in the same relative location, and only the
503 superproject&#8217;s URL needs to be provided: git-submodule will correctly
504 locate the submodule using the relative URL in .gitmodules.</p></div>
505 </dd>
506 <dt class="hdlist1">
507 status
508 </dt>
509 <dd>
511 Show the status of the submodules. This will print the SHA-1 of the
512 currently checked out commit for each submodule, along with the
513 submodule path and the output of <em>git describe</em> for the
514 SHA-1. Each SHA-1 will be prefixed with <tt>-</tt> if the submodule is not
515 initialized, <tt>+</tt> if the currently checked out submodule commit
516 does not match the SHA-1 found in the index of the containing
517 repository and <tt>U</tt> if the submodule has merge conflicts.
518 This command is the default command for <em>git submodule</em>.
519 </p>
520 <div class="paragraph"><p>If <em>--recursive</em> is specified, this command will recurse into nested
521 submodules, and show their status as well.</p></div>
522 </dd>
523 <dt class="hdlist1">
524 init
525 </dt>
526 <dd>
528 Initialize the submodules, i.e. register each submodule name
529 and url found in .gitmodules into .git/config.
530 The key used in .git/config is <tt>submodule.$name.url</tt>.
531 This command does not alter existing information in .git/config.
532 You can then customize the submodule clone URLs in .git/config
533 for your local setup and proceed to <tt>git submodule update</tt>;
534 you can also just use <tt>git submodule update --init</tt> without
535 the explicit <em>init</em> step if you do not intend to customize
536 any submodule locations.
537 </p>
538 </dd>
539 <dt class="hdlist1">
540 update
541 </dt>
542 <dd>
544 Update the registered submodules, i.e. clone missing submodules and
545 checkout the commit specified in the index of the containing repository.
546 This will make the submodules HEAD be detached unless <em>--rebase</em> or
547 <em>--merge</em> is specified or the key <tt>submodule.$name.update</tt> is set to
548 <tt>rebase</tt> or <tt>merge</tt>.
549 </p>
550 <div class="paragraph"><p>If the submodule is not yet initialized, and you just want to use the
551 setting as stored in .gitmodules, you can automatically initialize the
552 submodule with the --init option.</p></div>
553 <div class="paragraph"><p>If <em>--recursive</em> is specified, this command will recurse into the
554 registered submodules, and update any nested submodules within.</p></div>
555 </dd>
556 <dt class="hdlist1">
557 summary
558 </dt>
559 <dd>
561 Show commit summary between the given commit (defaults to HEAD) and
562 working tree/index. For a submodule in question, a series of commits
563 in the submodule between the given super project commit and the
564 index or working tree (switched by --cached) are shown. If the option
565 --files is given, show the series of commits in the submodule between
566 the index of the super project and the working tree of the submodule
567 (this option doesn&#8217;t allow to use the --cached option or to provide an
568 explicit commit).
569 </p>
570 </dd>
571 <dt class="hdlist1">
572 foreach
573 </dt>
574 <dd>
576 Evaluates an arbitrary shell command in each checked out submodule.
577 The command has access to the variables $name, $path, $sha1 and
578 $toplevel:
579 $name is the name of the relevant submodule section in .gitmodules,
580 $path is the name of the submodule directory relative to the
581 superproject, $sha1 is the commit as recorded in the superproject,
582 and $toplevel is the absolute path to the top-level of the superproject.
583 Any submodules defined in the superproject but not checked out are
584 ignored by this command. Unless given --quiet, foreach prints the name
585 of each submodule before evaluating the command.
586 If --recursive is given, submodules are traversed recursively (i.e.
587 the given shell command is evaluated in nested submodules as well).
588 A non-zero return from the command in any submodule causes
589 the processing to terminate. This can be overridden by adding <em>|| :</em>
590 to the end of the command.
591 </p>
592 <div class="paragraph"><p>As an example, <tt>git submodule foreach 'echo $path &#96;git
593 rev-parse HEAD&#96;'</tt> will show the path and currently checked out
594 commit for each submodule.</p></div>
595 </dd>
596 <dt class="hdlist1">
597 sync
598 </dt>
599 <dd>
601 Synchronizes submodules' remote URL configuration setting
602 to the value specified in .gitmodules. It will only affect those
603 submodules which already have an url entry in .git/config (that is the
604 case when they are initialized or freshly added). This is useful when
605 submodule URLs change upstream and you need to update your local
606 repositories accordingly.
607 </p>
608 <div class="paragraph"><p>"git submodule sync" synchronizes all submodules while
609 "git submodule sync -- A" synchronizes submodule "A" only.</p></div>
610 </dd>
611 </dl></div>
612 </div>
613 <h2 id="_options">OPTIONS</h2>
614 <div class="sectionbody">
615 <div class="dlist"><dl>
616 <dt class="hdlist1">
618 </dt>
619 <dt class="hdlist1">
620 --quiet
621 </dt>
622 <dd>
624 Only print error messages.
625 </p>
626 </dd>
627 <dt class="hdlist1">
629 </dt>
630 <dt class="hdlist1">
631 --branch
632 </dt>
633 <dd>
635 Branch of repository to add as submodule.
636 </p>
637 </dd>
638 <dt class="hdlist1">
640 </dt>
641 <dt class="hdlist1">
642 --force
643 </dt>
644 <dd>
646 This option is only valid for add and update commands.
647 When running add, allow adding an otherwise ignored submodule path.
648 When running update, throw away local changes in submodules when
649 switching to a different commit.
650 </p>
651 </dd>
652 <dt class="hdlist1">
653 --cached
654 </dt>
655 <dd>
657 This option is only valid for status and summary commands. These
658 commands typically use the commit found in the submodule HEAD, but
659 with this option, the commit stored in the index is used instead.
660 </p>
661 </dd>
662 <dt class="hdlist1">
663 --files
664 </dt>
665 <dd>
667 This option is only valid for the summary command. This command
668 compares the commit in the index with that in the submodule HEAD
669 when this option is used.
670 </p>
671 </dd>
672 <dt class="hdlist1">
674 </dt>
675 <dt class="hdlist1">
676 --summary-limit
677 </dt>
678 <dd>
680 This option is only valid for the summary command.
681 Limit the summary size (number of commits shown in total).
682 Giving 0 will disable the summary; a negative number means unlimited
683 (the default). This limit only applies to modified submodules. The
684 size is always limited to 1 for added/deleted/typechanged submodules.
685 </p>
686 </dd>
687 <dt class="hdlist1">
689 </dt>
690 <dt class="hdlist1">
691 --no-fetch
692 </dt>
693 <dd>
695 This option is only valid for the update command.
696 Don&#8217;t fetch new objects from the remote site.
697 </p>
698 </dd>
699 <dt class="hdlist1">
700 --merge
701 </dt>
702 <dd>
704 This option is only valid for the update command.
705 Merge the commit recorded in the superproject into the current branch
706 of the submodule. If this option is given, the submodule&#8217;s HEAD will
707 not be detached. If a merge failure prevents this process, you will
708 have to resolve the resulting conflicts within the submodule with the
709 usual conflict resolution tools.
710 If the key <tt>submodule.$name.update</tt> is set to <tt>merge</tt>, this option is
711 implicit.
712 </p>
713 </dd>
714 <dt class="hdlist1">
715 --rebase
716 </dt>
717 <dd>
719 This option is only valid for the update command.
720 Rebase the current branch onto the commit recorded in the
721 superproject. If this option is given, the submodule&#8217;s HEAD will not
722 be detached. If a merge failure prevents this process, you will have
723 to resolve these failures with <a href="git-rebase.html">git-rebase(1)</a>.
724 If the key <tt>submodule.$name.update</tt> is set to <tt>rebase</tt>, this option is
725 implicit.
726 </p>
727 </dd>
728 <dt class="hdlist1">
729 --reference &lt;repository&gt;
730 </dt>
731 <dd>
733 This option is only valid for add and update commands. These
734 commands sometimes need to clone a remote repository. In this case,
735 this option will be passed to the <a href="git-clone.html">git-clone(1)</a> command.
736 </p>
737 <div class="paragraph"><p><strong>NOTE</strong>: Do <strong>not</strong> use this option unless you have read the note
738 for <a href="git-clone.html">git-clone(1)</a>'s --reference and --shared options carefully.</p></div>
739 </dd>
740 <dt class="hdlist1">
741 --recursive
742 </dt>
743 <dd>
745 This option is only valid for foreach, update and status commands.
746 Traverse submodules recursively. The operation is performed not
747 only in the submodules of the current repo, but also
748 in any nested submodules inside those submodules (and so on).
749 </p>
750 </dd>
751 <dt class="hdlist1">
752 &lt;path&gt;&#8230;
753 </dt>
754 <dd>
756 Paths to submodule(s). When specified this will restrict the command
757 to only operate on the submodules found at the specified paths.
758 (This argument is required with add).
759 </p>
760 </dd>
761 </dl></div>
762 </div>
763 <h2 id="_files">FILES</h2>
764 <div class="sectionbody">
765 <div class="paragraph"><p>When initializing submodules, a .gitmodules file in the top-level directory
766 of the containing repository is used to find the url of each submodule.
767 This file should be formatted in the same way as <tt>$GIT_DIR/config</tt>. The key
768 to each submodule url is "submodule.$name.url". See <a href="gitmodules.html">gitmodules(5)</a>
769 for details.</p></div>
770 </div>
771 <h2 id="_git">GIT</h2>
772 <div class="sectionbody">
773 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
774 </div>
775 <div id="footer">
776 <div id="footer-text">
777 Last updated 2011-07-23 00:49:30 UTC
778 </div>
779 </div>
780 </body>
781 </html>