These are the steps to extract a directory from a git repository (with all its history commit), create a new repository from this directory, and optionally remove it from the original one.
To the ones that are here to copy-paste code, this is an example which removes the MODULE directory from REPO repository.
Clone the original repository: