Created
May 19, 2022 23:18
-
-
Save dnedrow/93915314a15c8a0ce22a16ae792ac134 to your computer and use it in GitHub Desktop.
This script will add all submodules from just a .gitmodules file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # This script will add all submodules from just a .gitmodules file | |
| # | |
| # This script copied from https://www.willhallonline.co.uk/blog/2019-03-05-scripting-adding-gitmodules/ | |
| # One addition is the '--force' directive on 'submodule add'. | |
| 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 --force $url $path | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment