To transfer a directory from one Git repository to another while preserving its history, follow these steps:
- Clone the SOURCE REPOSITORY to your local machine.
- Remove the origin from the local copy of the SOURCE REPOSITORY.
git remote remove origin
- Use Git filter-repo to filter the repository's history to include only the files you need, specifying the DIRECTORY_PATH.