Skip to content

Instantly share code, notes, and snippets.

@aroemen
Created February 25, 2013 02:39
Show Gist options
  • Save aroemen/5027030 to your computer and use it in GitHub Desktop.
Save aroemen/5027030 to your computer and use it in GitHub Desktop.
Restore git submodules from .gitmodules. Since git submodule init only considers submodules that already are in the index (i.e. "staged") for initialization this short script parses .gitmodules, and each url and path pair.
#!/bin/sh
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $path
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment