LinuxCommandLibrary

git-submodule

Manage embedded external repositories within a project

TLDR

Add submodule

$ git submodule add [url] [path]
copy
Initialize submodules
$ git submodule init
copy
Update submodules
$ git submodule update
copy
Clone with submodules
$ git submodule update --init --recursive
copy
Show submodule status
$ git submodule status
copy
Pull submodule changes
$ git submodule update --remote
copy
Remove submodule
$ git submodule deinit [path] && git rm [path]
copy
Foreach command
$ git submodule foreach "[command]"
copy

SYNOPSIS

git submodule command [options]

DESCRIPTION

git submodule manages submodules, which are external Git repositories embedded within a parent repository at specific paths. Each submodule tracks a particular commit of the external repository.
Submodules allow projects to include and track dependencies or shared components while keeping their histories separate. Use `update --init --recursive` after cloning to populate all submodule contents.

PARAMETERS

--init

Initialize during update.
--recursive
Recursive operation.
--remote
Use remote tracking branch.
-f, --force
Force operation.

CONFIGURATION

.gitmodules

Configuration file mapping submodule names to their repository URLs and local paths.

SUBCOMMANDS

add

Add submodule.
init
Initialize submodules.
update
Update submodules.
status
Show status.
deinit
Unregister submodule.
sync
Sync URLs.
foreach
Run command in each.
summary
Show commit summary.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community