You've successfully subscribed to MyPad Blog
Great! Next, complete checkout for full access to MyPad Blog
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

Restore gitsubmodules from a previous project

Restore gitsubmodules from a previous project

Ever wanted to use a previous project to seed a new one?

We often have to do that. With re-using an existing project, we typically need to see our git repo with also the submodules that were used.

Here is a script that does just that!

# credit:
set -e

git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
    while read path_key path
        url_key=$(echo $path_key | sed 's/\.path/.url/')
        url=$(git config -f .gitmodules --get "$url_key")
        git submodule add $url $path

Simply run it bash ./shell/ and all the submodules should be in the new repo!