Skip to content

Instantly share code, notes, and snippets.

@aaronjorbin
Created December 23, 2015 16:44
Show Gist options
  • Save aaronjorbin/40d37d7720292b829cb0 to your computer and use it in GitHub Desktop.
Save aaronjorbin/40d37d7720292b829cb0 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' > tmpfile
while read -u 3 path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
read -p "Are you sure you want to delete $path and re-initialize as a new submodule? " yn
case $yn in
[Yy]* ) rm -rf $path; git submodule add $url $path; echo "$path has been initialized";;
[Nn]* ) echo "ok. Skipping $path";;
* ) echo "Please answer yes or no.";;
esac
done 3<tmpfile
rm tmpfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment