Skip to content

Instantly share code, notes, and snippets.

@jpolvora
Created August 31, 2014 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpolvora/e0c168263ea4d57fff6d to your computer and use it in GitHub Desktop.
Save jpolvora/e0c168263ea4d57fff6d to your computer and use it in GitHub Desktop.
Convert a Git SubModule to Subtrees
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