#!/bin/bash # Checkout and update source for all registered submodules (.gitmodules). # Optionally 'git pull' on each submodule to check for updates. # Ensure all submodules (and child submodules) are checked-out git submodule update --init --recursive # Update submodules' remotes based on .gitmodules git submodule sync if [ "$1" = "pull" ]; then # Fetch & pull any new updates from submodule's origin # [http://scribu.net/blog/git-alias-for-updating-submodules.html] git submodule foreach 'git fetch origin --tags; git checkout master; git pull' fi