I would like to copy a list of files from a given directory in a repository A to repository B with its commit history.
The internet is full with solutions for copying a full directory with all its content: Git: Copy history of file from one repository to another or https://mattsch.com/2015/06/19/move-directory-from-one-repository-to-another-preserving-history/
Those solution assumed I would like to copy all files in a subdirectory, which is not my case. I would like to copy a subset of files from a directory with its commit history from one repository to another.
For example:
I would like to copy https://github.com/carla-simulator/scenario_runner/blob/master/srunner/examples/catalogs/EnvironmentCatalog.xosc to another repository B and to place it there at root (./
).
The suggested solution from @jingx solved almost this problem.
Using
git am <the-patch-files>
the file will be placed in repository B at B/examples/catalogs/EnvironmentCatalog.xosc
instead of B/EnvironmentCatalog.xosc
After moving the files to the "right" place, an additional commit is needed due to this directory change.
Unfortunately I was unable to do this using this method above.
How can I solve this problem?