I know there is a big thread Detach subdirectory into separate Git repository but there are always some variations. My task differentiates from the above question is that there are some files instead of a subdirectory.
Ex.
XYZ/
.git/
XY1/
ABC/foo.py
ABC/bar.py
ABC/asdf.py
ABC/...
And I would like to extract foo.py and bar.py into a separate Git repository.
My first trial is to make a subdirectory for these 2 files and make use of method mentioned in 1:
$ mkdir foobar
$ git mv ABC/foo.py ABC/bar.py foobar
$ git commit -m '...'
$ git filter-branch --subdirectory-filter foobar HEAD
So far so good except the commit history is lost. Any idea for that?