If you have several projects in one git tree, perhaps something like:
repo/
.git/
proj1/
proj2/
And you want several individual git repos:
proj1/
.git/
proj2/
.git/
Then to take all sub-folders from ~/git/src
and create new git repos in ~/git
:
set -e
srcrepo=~/git/src
cd git_tmp
git clone $srcrepo ./orig
mkdir new
cd new
for dir in ../orig/*;
do
dir=$(basename $dir)
git clone ../orig $dir
pushd $dir
git filter-branch --subdirectory-filter $dir HEAD -- --all
git reset --hard
git gc --aggressive
git prune
popd
git clone --bare $dir ~/git/$dir
done
rm -rf ~/git_tmp/*