git filter-branch --prune-empty --tree-filter '
if [[ ! -e foo/bar ]]; then
mkdir -p foo/bar
git ls-tree --name-only $GIT_COMMIT | xargs -I files mv files foo/bar
fi'Where foo/bar is the new dir where your files will be placed.
Source: http://stackoverflow.com/a/4042965/1863234. Thanks to Dan Moulding.
There is also a Github help article that explains how to do the whole thing: https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/