git-submodule.txt 2.6 KB
Newer Older
L
Lars Hjemli 已提交
1 2 3 4 5 6 7 8 9 10
git-submodule(1)
================

NAME
----
git-submodule - Initialize, update or inspect submodules


SYNOPSIS
--------
11
[verse]
12 13 14
'git-submodule' [--quiet] add [-b branch] [--] <repository> [<path>]
'git-submodule' [--quiet] status [--cached] [--] [<path>...]
'git-submodule' [--quiet] [init|update] [--] [<path>...]
L
Lars Hjemli 已提交
15 16 17 18


COMMANDS
--------
19 20
add::
	Add the given repository as a submodule at the given path
21 22 23
	to the changeset to be committed next.  If path is a valid
	repository within the project, it is added as is. Otherwise,
	repository is cloned at the specified path. path is added to the
24 25
	changeset and registered in .gitmodules.   If no path is
	specified, the path is deduced from the repository specification.
26 27 28
	If the repository url begins with ./ or ../, it is stored as
	given but resolved as a relative path from the main project's
	url when cloning.
29

L
Lars Hjemli 已提交
30 31 32
status::
	Show the status of the submodules. This will print the SHA-1 of the
	currently checked out commit for each submodule, along with the
33
	submodule path and the output of linkgit:git-describe[1] for the
L
Lars Hjemli 已提交
34 35 36 37 38 39
	SHA-1. Each SHA-1 will be prefixed with `-` if the submodule is not
	initialized and `+` if the currently checked out submodule commit
	does not match the SHA-1 found in the index of the containing
	repository. This command is the default command for git-submodule.

init::
40
	Initialize the submodules, i.e. register in .git/config each submodule
41 42
	name and url found in .gitmodules. The key used in .git/config is
	`submodule.$name.url`. This command does not alter existing information
43
	in .git/config.
L
Lars Hjemli 已提交
44 45

update::
46 47 48
	Update the registered submodules, i.e. clone missing submodules and
	checkout the commit specified in the index of the containing repository.
	This will make the submodules HEAD be detached.
L
Lars Hjemli 已提交
49 50 51 52 53 54 55


OPTIONS
-------
-q, --quiet::
	Only print error messages.

56 57 58
-b, --branch::
	Branch of repository to add as submodule.

L
Lars Hjemli 已提交
59 60 61 62 63 64 65 66 67 68 69
--cached::
	Display the SHA-1 stored in the index, not the SHA-1 of the currently
	checked out submodule commit. This option is only valid for the
	status command.

<path>::
	Path to submodule(s). When specified this will restrict the command
	to only operate on the submodules found at the specified paths.

FILES
-----
70
When initializing submodules, a .gitmodules file in the top-level directory
L
Lars Hjemli 已提交
71
of the containing repository is used to find the url of each submodule.
72
This file should be formatted in the same way as `$GIT_DIR/config`. The key
73
to each submodule url is "submodule.$name.url".  See linkgit:gitmodules[5]
74
for details.
L
Lars Hjemli 已提交
75 76 77 78 79 80 81 82


AUTHOR
------
Written by Lars Hjemli <hjemli@gmail.com>

GIT
---
83
Part of the linkgit:git[7] suite