
# from http://stackoverflow.com/questions/14759345/how-to-split-a-git-repository-and-follow-directory-renames

git filter-branch --prune-empty --index-filter '
    # Delete files which are NOT needed
    git ls-files -z | egrep -zv  "^(components/specification)" | 
        xargs -0 git rm --cached -q             
    # Move files to root directory
    git ls-files -s | sed -e "s-\t\(components/specification\)/-\t-" |
        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
        git update-index --index-info &&
        ( test ! -f "$GIT_INDEX_FILE.new" \
            || mv -f "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE" )
'