Home Explore Blog CI



git

1st chunk of `Documentation/git-submodule.adoc`
65715247a28b94c23b2717fd5c496b6ad8386c76a2d7572a0000000100000fa0
git-submodule(1)
================

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


SYNOPSIS
--------
[verse]
'git submodule' [--quiet] [--cached]
'git submodule' [--quiet] add [<options>] [--] <repository> [<path>]
'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
'git submodule' [--quiet] init [--] [<path>...]
'git submodule' [--quiet] deinit [-f|--force] (--all|[--] <path>...)
'git submodule' [--quiet] update [<options>] [--] [<path>...]
'git submodule' [--quiet] set-branch [<options>] [--] <path>
'git submodule' [--quiet] set-url [--] <path> <newurl>
'git submodule' [--quiet] summary [<options>] [--] [<path>...]
'git submodule' [--quiet] foreach [--recursive] <command>
'git submodule' [--quiet] sync [--recursive] [--] [<path>...]
'git submodule' [--quiet] absorbgitdirs [--] [<path>...]


DESCRIPTION
-----------
Inspects, updates and manages submodules.

For more information about submodules, see linkgit:gitsubmodules[7].

COMMANDS
--------
With no arguments, shows the status of existing submodules.  Several
subcommands are available to perform operations on the submodules.

add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--ref-format <format>] [--depth <depth>] [--] <repository> [<path>]::
	Add the given repository as a submodule at the given path
	to the changeset to be committed next to the current
	project: the current project is termed the "superproject".
+
<repository> is the URL of the new submodule's origin repository.
This may be either an absolute URL, or (if it begins with ./
or ../), the location relative to the superproject's default remote
repository (Please note that to specify a repository 'foo.git'
which is located right next to a superproject 'bar.git', you'll
have to use `../foo.git` instead of `./foo.git` - as one might expect
when following the rules for relative URLs - because the evaluation
of relative URLs in Git is identical to that of relative directories).
+
The default remote is the remote of the remote-tracking branch
of the current branch. If no such remote-tracking branch exists or
the HEAD is detached, "origin" is assumed to be the default remote.
If the superproject doesn't have a default remote configured
the superproject is its own authoritative upstream and the current
working directory is used instead.
+
The optional argument <path> is the relative location for the cloned
submodule to exist in the superproject. If <path> is not given, the
canonical part of the source repository is used ("repo" for
"/path/to/repo.git" and "foo" for "host.xz:foo/.git"). If <path>
exists and is already a valid Git repository, then it is staged
for commit without cloning. The <path> is also used as the submodule's
logical name in its configuration entries unless `--name` is used
to specify a logical name.
+
The given URL is recorded into `.gitmodules` for use by subsequent users
cloning the superproject. If the URL is given relative to the
superproject's repository, the presumption is the superproject and
submodule repositories will be kept together in the same relative
location, and only the superproject's URL needs to be provided.
git-submodule will correctly locate the submodule using the relative
URL in `.gitmodules`.
+
If `--ref-format <format>`  is specified, the ref storage format of newly
cloned submodules will be set accordingly.

status [--cached] [--recursive] [--] [<path>...]::
	Show the status of the submodules. This will print the SHA-1 of the
	currently checked out commit for each submodule, along with the
	submodule path and the output of 'git describe' for the
	SHA-1. Each SHA-1 will possibly be prefixed with `-` if the submodule is
	not initialized, `+` if the currently checked out submodule commit
	does not match the SHA-1 found in the index of the containing
	repository and `U` if the submodule has merge conflicts.
+
If `--cached` is specified, this command will instead print the SHA-1
recorded in the superproject for

Title: Git Submodule Command
Summary
The git-submodule command is used to initialize, update, or inspect submodules within a Git repository, providing various subcommands for managing and operating on submodules. It allows users to add new submodules, update existing ones, and check their status, as well as perform other operations such as setting branch and URL information, summarizing submodule changes, and synchronizing submodules with their remote repositories.