Created
June 14, 2018 17:33
-
-
Save balkian/4ff59e1673a1a754e14f8fd619581cbf to your computer and use it in GitHub Desktop.
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/bash -x | |
# extract the list of submodules from .gitmodule | |
cat .gitmodules |while read i | |
do | |
if [[ $i == \[submodule* ]]; then | |
echo converting $i | |
# extract the module's prefix | |
mpath=$(echo $i | cut -d\" -f2) | |
# skip two lines | |
read i; read i; | |
# extract the url of the submodule | |
murl=$(echo $i|cut -d\= -f2|xargs) | |
# extract the module name | |
mname=$(basename $mpath) | |
# deinit the module | |
git submodule deinit $mpath | |
# remove the module from git | |
git rm -r --cached $mpath | |
# remove the module from the filesystem | |
rm -rf $mpath | |
# commit the change | |
git commit -m "Removed $mpath submodule" | |
# add the remote | |
git remote add -f $mname $murl | |
# add the subtree | |
git subtree add --prefix $mpath $mname master --squash | |
# fetch the files | |
git fetch $murl master | |
fi | |
done | |
git rm .gitmodules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment