Skip to content

Instantly share code, notes, and snippets.

@thinsoldier
Created October 19, 2015 17:29
Show Gist options
  • Save thinsoldier/281daa0a3b63c7774abe to your computer and use it in GitHub Desktop.
Save thinsoldier/281daa0a3b63c7774abe to your computer and use it in GitHub Desktop.
When you want to use a pre-existing .gitmodules file to set up submodules on another repository.
#!/bin/sh
# http://stackoverflow.com/a/11258810/1154693
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