1
0
mirror of https://github.com/balkian/gists.git synced 2024-11-01 08:01:44 +00:00
gists/repos/4ff59e1673a1a754e14f8fd619581cbf/submodules2subtrees.sh
J. Fernando Sánchez 7d714103f6 Add 'repos/4ff59e1673a1a754e14f8fd619581cbf/' from commit '50b94353e49ddf9a453ddb8730b34dacb101880a'
git-subtree-dir: repos/4ff59e1673a1a754e14f8fd619581cbf
git-subtree-mainline: 2ee5da5427
git-subtree-split: 50b94353e4
2021-10-30 15:12:28 +02:00

42 lines
875 B
Bash

#!/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