Profile picture

Git Pull With Submodule

Profile picture

Raphael Tang / May 01, 2021

1 min read

#tips

For a repo with submodules, we can pull all submodules with

git submodule update --init --recursive

for the first time. All submodules will be pulled down locally.

To update submodules, we can use

For git 1.8.2 or above, the option --remote was added to support updating to latest tips of remote branches

git submodule update --recursive --remote

This has the added benefit of respecting any "non default" branches specified in the .gitmodules or .git/config files.

For git 1.7.3 or above you can use

git submodule update --recursive

or simply

git pull --recurse-submodules

TL;DR

For a repo with no pulled submodules yet, do

git submodule update --init --recursive

To update submodules, do

git submodule update --recursive --remote

References:

  1. Easy way to pull latest of all git submodules

Subscribe to the newsletter

Get emails from me about software development, SaaS, and early access to new articles.