Let's say you have the repository:
myCode/megaProject/moduleA
myCode/megaProject/moduleB
Over time (months), you re-organise the project. Refactoring the code to make the modules independent. Files in the megaProject directory get moved into their own directories. Emphasis on move - the history of these files is preserved.
myCode/megaProject
myCode/moduleA
myCode/moduleB
Now you wish to move these modules to their own GIT repos. Leaving the original with just megaProject on its own.
myCode/megaProject
newRepoA/moduleA
newRepoB/moduleB
The filter-branch
command is documentated to do this but it doesn't follow history when files were moved outside of the target directory. So the history begins when the files were moved into their new directory, not the history the files had then they lived in the old megaProject directory.
How to split a GIT history based on a target directory, and, follow history outside of this path - leaving only commit history related to these files and nothing else?
The numerous other answers on SO focus on generally splitting apart the repo - but make no mention of splitting apart and following the move history.