Git Move Directory from Repo to New Repo with History

Move a directory from a git repository to its own repository, with history

You can use filter-branch

To rewrite the repository to look as if foodir/ had been its project root, and discard all other history:

git filter-branch --subdirectory-filter foodir -- --all