Skip to content

Instantly share code, notes, and snippets.

@bewt85
Created June 8, 2014 19:12
Show Gist options
  • Save bewt85/229420f124e807766321 to your computer and use it in GitHub Desktop.
Save bewt85/229420f124e807766321 to your computer and use it in GitHub Desktop.
Script to help split a project into sub-modules
#!/bin/bash
set -ex
ROOT_DIR=$(cd $(dirname $1); pwd)/$(basename $1)
START_DIR=$(pwd)
[[ -d ${START_DIR}/splits ]] || mkdir ${START_DIR}/splits
for subProject in $(find $ROOT_DIR -mindepth 1 -maxdepth 1 -type d | grep -v git); do
cd $ROOT_DIR
dest_dir=${START_DIR}/splits/$(basename $subProject)
cp -r ${ROOT_DIR} $dest_dir
cd $dest_dir
git filter-branch --subdirectory-filter $(basename $subProject)/ -- master
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment