Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Created June 29, 2023 14:35
Show Gist options
  • Save raphaelchaib/c2698816779e1fdbe087b94c281476b9 to your computer and use it in GitHub Desktop.
Save raphaelchaib/c2698816779e1fdbe087b94c281476b9 to your computer and use it in GitHub Desktop.
Git Submodules: Read the .gitmodules file and add them to the index, following path rules
#!/bin/sh
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key local_path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $local_path
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment