some steps from http://www.pixelite.co.nz/article/extracting-file-folder-from-git-repository-with-full-git-history/
git log --pretty=email --patch-with-stat --reverse --full-index --binary -- <path/to/file_or_folder> [path/to/additional/file/or/folder] > /tmp/<patch name>`- from
master,git checkout -b <name of pre-release branch> git checkout --orphan <name of orphan branch>git resetto unstage the files that already existed in the repositoryrm -rf *to remove the previous files that are now unstaged (be careful to not remove the.git/directory)git am < /tmp/<patch name>to apply the patch to the orphan branchgit merge <name of pre-release branch> --allow-unrelated-histories- verify that existing and extracted/imported tests pass
- repeat with additional patches if missing dependencies are discovered
https://github.com/newren/git-filter-repo/#solving-this-with-filter-repo is another option that i've used successfully. this is especially useful when keeping tags is desired.