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 [-b branch]
10                     [--reference <repository>] [--] <repository> [<path>]
11       git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
12       git submodule [--quiet] init [--] [<path>...]
13       git submodule [--quiet] update [--init] [-N|--no-fetch] [--rebase]
14                     [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
15       git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
16       git submodule [--quiet] foreach [--recursive] <command>
17       git submodule [--quiet] sync [--] [<path>...]
18
19

DESCRIPTION

21       Submodules allow foreign repositories to be embedded within a dedicated
22       subdirectory of the source tree, always pointed at a particular commit.
23
24       They are not to be confused with remotes, which are meant mainly for
25       branches of the same project; submodules are meant for different
26       projects you would like to make part of your source tree, while the
27       history of the two projects still stays completely independent and you
28       cannot modify the contents of the submodule from within the main
29       project. If you want to merge the project histories and want to treat
30       the aggregated whole as a single project from then on, you may want to
31       add a remote for the other project and use the subtree merge strategy,
32       instead of treating the other project as a submodule. Directories that
33       come from both projects can be cloned and checked out as a whole if you
34       choose to go that route.
35
36       Submodules are composed from a so-called gitlink tree entry in the main
37       repository that refers to a particular commit object within the inner
38       repository that is completely separate. A record in the .gitmodules
39       file at the root of the source tree assigns a logical name to the
40       submodule and describes the default URL the submodule shall be cloned
41       from. The logical name can be used for overriding this URL within your
42       local repository configuration (see submodule init).
43
44       This command will manage the tree entries and contents of the
45       gitmodules file for you, as well as inspect the status of your
46       submodules and update them. When adding a new submodule to the tree,
47       the add subcommand is to be used. However, when pulling a tree
48       containing submodules, these will not be checked out by default; the
49       init and update subcommands will maintain submodules checked out and at
50       appropriate revision in your working tree. You can briefly inspect the
51       up-to-date status of your submodules using the status subcommand and
52       get a detailed overview of the difference between the index and
53       checkouts using the summary subcommand.
54

COMMANDS

56       add
57           Add the given repository as a submodule at the given path to the
58           changeset to be committed next to the current project: the current
59           project is termed the "superproject".
60
61           This requires at least one argument: <repository>. The optional
62           argument <path> is the relative location for the cloned submodule
63           to exist in the superproject. If <path> is not given, the
64           "humanish" part of the source repository is used ("repo" for
65           "/path/to/repo.git" and "foo" for "host.xz:foo/.git").
66
67           <repository> is the URL of the new submodule’s origin repository.
68           This may be either an absolute URL, or (if it begins with ./ or
69           ../), the location relative to the superproject’s origin
70           repository.
71
72           <path> is the relative location for the cloned submodule to exist
73           in the superproject. If <path> does not exist, then the submodule
74           is created by cloning from the named URL. If <path> does exist and
75           is already a valid git repository, then this is added to the
76           changeset without cloning. This second form is provided to ease
77           creating a new submodule from scratch, and presumes the user will
78           later push the submodule to the given URL.
79
80           In either case, the given URL is recorded into .gitmodules for use
81           by subsequent users cloning the superproject. If the URL is given
82           relative to the superproject’s repository, the presumption is the
83           superproject and submodule repositories will be kept together in
84           the same relative location, and only the superproject’s URL needs
85           to be provided: git-submodule will correctly locate the submodule
86           using the relative URL in .gitmodules.
87
88       status
89           Show the status of the submodules. This will print the SHA-1 of the
90           currently checked out commit for each submodule, along with the
91           submodule path and the output of git describe for the SHA-1. Each
92           SHA-1 will be prefixed with - if the submodule is not initialized
93           and + if the currently checked out submodule commit does not match
94           the SHA-1 found in the index of the containing repository. This
95           command is the default command for git submodule.
96
97           If --recursive is specified, this command will recurse into nested
98           submodules, and show their status as well.
99
100       init
101           Initialize the submodules, i.e. register each submodule name and
102           url found in .gitmodules into .git/config. The key used in
103           .git/config is submodule.$name.url. This command does not alter
104           existing information in .git/config. You can then customize the
105           submodule clone URLs in .git/config for your local setup and
106           proceed to git submodule update; you can also just use git
107           submodule update --init without the explicit init step if you do
108           not intend to customize any submodule locations.
109
110       update
111           Update the registered submodules, i.e. clone missing submodules and
112           checkout the commit specified in the index of the containing
113           repository. This will make the submodules HEAD be detached unless
114           --rebase or --merge is specified or the key submodule.$name.update
115           is set to rebase or merge.
116
117           If the submodule is not yet initialized, and you just want to use
118           the setting as stored in .gitmodules, you can automatically
119           initialize the submodule with the --init option.
120
121           If --recursive is specified, this command will recurse into the
122           registered submodules, and update any nested submodules within.
123
124       summary
125           Show commit summary between the given commit (defaults to HEAD) and
126           working tree/index. For a submodule in question, a series of
127           commits in the submodule between the given super project commit and
128           the index or working tree (switched by --cached) are shown. If the
129           option --files is given, show the series of commits in the
130           submodule between the index of the super project and the working
131           tree of the submodule (this option doesn’t allow to use the
132           --cached option or to provide an explicit commit).
133
134       foreach
135           Evaluates an arbitrary shell command in each checked out submodule.
136           The command has access to the variables $name, $path and $sha1:
137           $name is the name of the relevant submodule section in .gitmodules,
138           $path is the name of the submodule directory relative to the
139           superproject, and $sha1 is the commit as recorded in the
140           superproject. Any submodules defined in the superproject but not
141           checked out are ignored by this command. Unless given --quiet,
142           foreach prints the name of each submodule before evaluating the
143           command. If --recursive is given, submodules are traversed
144           recursively (i.e. the given shell command is evaluated in nested
145           submodules as well). A non-zero return from the command in any
146           submodule causes the processing to terminate. This can be
147           overridden by adding || : to the end of the command.
148
149           As an example, git submodule foreach ´echo $path `git rev-parse
150           HEAD`´ will show the path and currently checked out commit for each
151           submodule.
152
153       sync
154           Synchronizes submodules´ remote URL configuration setting to the
155           value specified in .gitmodules. This is useful when submodule URLs
156           change upstream and you need to update your local repositories
157           accordingly.
158
159           "git submodule sync" synchronizes all submodules while "git
160           submodule sync — A" synchronizes submodule "A" only.
161

OPTIONS

163       -q, --quiet
164           Only print error messages.
165
166       -b, --branch
167           Branch of repository to add as submodule.
168
169       --cached
170           This option is only valid for status and summary commands. These
171           commands typically use the commit found in the submodule HEAD, but
172           with this option, the commit stored in the index is used instead.
173
174       --files
175           This option is only valid for the summary command. This command
176           compares the commit in the index with that in the submodule HEAD
177           when this option is used.
178
179       -n, --summary-limit
180           This option is only valid for the summary command. Limit the
181           summary size (number of commits shown in total). Giving 0 will
182           disable the summary; a negative number means unlimited (the
183           default). This limit only applies to modified submodules. The size
184           is always limited to 1 for added/deleted/typechanged submodules.
185
186       -N, --no-fetch
187           This option is only valid for the update command. Don’t fetch new
188           objects from the remote site.
189
190       --merge
191           This option is only valid for the update command. Merge the commit
192           recorded in the superproject into the current branch of the
193           submodule. If this option is given, the submodule’s HEAD will not
194           be detached. If a merge failure prevents this process, you will
195           have to resolve the resulting conflicts within the submodule with
196           the usual conflict resolution tools. If the key
197           submodule.$name.update is set to merge, this option is implicit.
198
199       --rebase
200           This option is only valid for the update command. Rebase the
201           current branch onto the commit recorded in the superproject. If
202           this option is given, the submodule’s HEAD will not be detached. If
203           a merge failure prevents this process, you will have to resolve
204           these failures with git-rebase(1). If the key
205           submodule.$name.update is set to rebase, this option is implicit.
206
207       --reference <repository>
208           This option is only valid for add and update commands. These
209           commands sometimes need to clone a remote repository. In this case,
210           this option will be passed to the git-clone(1) command.
211
212           NOTE: Do not use this option unless you have read the note for git-
213           clone(1)´s --reference and --shared options carefully.
214
215       --recursive
216           This option is only valid for foreach, update and status commands.
217           Traverse submodules recursively. The operation is performed not
218           only in the submodules of the current repo, but also in any nested
219           submodules inside those submodules (and so on).
220
221       <path>...
222           Paths to submodule(s). When specified this will restrict the
223           command to only operate on the submodules found at the specified
224           paths. (This argument is required with add).
225

FILES

227       When initializing submodules, a .gitmodules file in the top-level
228       directory of the containing repository is used to find the url of each
229       submodule. This file should be formatted in the same way as
230       $GIT_DIR/config. The key to each submodule url is
231       "submodule.$name.url". See gitmodules(5) for details.
232

AUTHOR

234       Written by Lars Hjemli <hjemli@gmail.com[1]>
235

GIT

237       Part of the git(1) suite
238

NOTES

240        1. hjemli@gmail.com
241           mailto:hjemli@gmail.com
242
243
244
245Git 1.7.1                         08/16/2017                  GIT-SUBMODULE(1)
Impressum