Created
August 31, 2014 09:13
-
-
Save jpolvora/e0c168263ea4d57fff6d to your computer and use it in GitHub Desktop.
Convert a Git SubModule to Subtrees
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
cat .gitmodules |while read i | |
do | |
if [[ $i == \[submodule* ]]; then | |
mpath=$(echo $i | cut -d\" -f2) | |
read i; read i; | |
murl=$(echo $i|cut -d\ -f3) | |
mcommit=`eval "git submodule status ${mpath} |cut -d\ -f2"` | |
mname=$(basename $mpath) | |
echo -e "$name\t$mpath\t$murl\t$mcommit" | |
git submodule deinit $mpath | |
git rm --cached $mpath | |
rm -rf $mpath | |
git remote add $mname $murl | |
git fetch $mname | |
git branch _$mname $mcommit | |
git read-tree --prefix=$mpath/ -u _$mname | |
fi | |
done | |
git rm .gitmodules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment