Created
January 3, 2014 18:22
-
-
Save Voronenko/8243339 to your computer and use it in GitHub Desktop.
This shell file can be used to re-checkout git submodules basing on .gitmodules file
This file contains 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/bash | |
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' > tempfile | |
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 rm -r $path; git submodule add -b master $url $path; echo "$path has been initialized";; | |
[Nn]* ) exit;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done 3<tempfile | |
rm tempfile | |
git submodule init | |
git submodule update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment