This question is based on Detach many subdirectories into a new, separate Git repository
My repository structure looks like this:
/apps
/AAA
/BBB
/CCC
/libs
/XXX
/YYY
/ZZZ
And I would like this instead:
/AAA
/XXX
The proposed solutions in the linked question keep the original paths of the folders. I would like instead to extract a set of folders located in different paths in a new repository, where all the folder are on root.
The other constraint, is that the commit history could involve both folders together, and I would like to preserve in the same way. For example, suppose the log in the original repository contains:
"My commit message"
/apps/AAA/file1.txt
/libs/XXX/file2.txt
I would like to see the equivalent in the new repo:
"My commit message"
/AAA/file1.txt
/XXX/file2.txt
How to achieve this?