I put together a solution based on other answers here but had to still do some research. This post is similar to others but fills in the pieces I was missing from the others. Hopefully, it will save someone some time.
In my case, there was an additional directory level in the target repo compared with the source repo. In other words, the top-level folder in the source repo, source-top-level
, was contained by a parent, target-top-level
, in the target repo. However, since there were no errors, I couldn't be sure that was the issue. So I used --verbose
, which shows the errors and I could confirm that indeed it was the issue.
I then checked the git documentation for the --directory
option. It allows you to specify a string that will be prepended to the path of each of the files in the patch:
--directory=<root>
Prepend <root> to all filenames.
By specifying --directory=target-top-level
it transformed each path, source-top-level/some-path
, to target-top-level/source-top-level/some-path
and with that the git apply
was successful.