What I want is similar to this question. However, I want the directory that is split into a separate repo to remain a subdirectory in that repo:
I have this:
A cleaner method:
git filter-branch --index-filter '
git read-tree --empty
git reset $GIT_COMMIT path/to/dir
' \
-- --all -- path/to/dir
or to stick with just core commands, sub in git read-tree --prefix=path/to/dir/ $GIT_COMMIT:path/to/dir
for the reset.
Specifying path/to/dir
on the rev-list args does the pruning early, with a filter this cheap it doesn't matter much but it's good to avoid the wasted effort anyway.