Skip to content

Instantly share code, notes, and snippets.

@enima007
Last active September 22, 2022 13:59
Show Gist options
  • Save enima007/56e39df0d750de4278a67cc37d328eb2 to your computer and use it in GitHub Desktop.
Save enima007/56e39df0d750de4278a67cc37d328eb2 to your computer and use it in GitHub Desktop.

Cloning a repo containing submodules.

git clone --recursive -j8 [-b branch-name] <repo-url>

Example

git clone --recursive -j8 -b develop [email protected]:path/to/repo.git

Load submodules for a cloned repo.

git submodule update --init --recursive

The "--recursive" parameter is added for nested submodules

Pull changes including submodules

git pull --recurse-submodules

Pull submodules changes

git submodule update

Adding a new submodule

git submodule add <repo-url> <submodule-path>

## Initialize an existing submodule

git submodule init

Delete a submodule from a parent repository

git rm -f <submodule-path>

Configuration settings

Get better diffs when a submodule changes

git config diff.submodule = log

Fetch submodules updates when parent repo gets fetched

git config fetch.recurseSubmodules = on-demand 

Display submodules status when we check parent repo for updates

git config status.submoduleSummary = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment