« Back to Index

[Update all submodules for a repo with a single command]

View original Gist on GitHub

Tags: #git #submodules

update-submodules.sh

# There are two ways to achieve the same thing, the first is more idiomatic (the second is a more general purpose solution).

# 1.
# Update the registered submodules to match what the superproject expects. [1]
git submodule update --init --recursive

# 2.
# Evaluates an arbitrary shell command in each checked out submodule. [2]
git submodule foreach git pull origin master

# Footnotes
#
# 1. https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-update--init--remote-N--no-fetch--no-recommend-shallow-f--force--checkout--rebase--merge--referenceltrepositorygt--depthltdepthgt--recursive--jobsltngt--no-single-branch--ltpathgt82308203
# 2. # https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-foreach--recursiveltcommandgt