Last Updated: February 25, 2016
·
1.079K
· igosuki

Git, format and apply a patch after moving or deleting files in another repository or branch

To create a list of patches between two commits, and exclude the files that have moved outside of the repo
git format-patch [SHA1..SHA2] -- . ":(exclude)folder_1" ":(exclude)folder_2"...

Checkout the target branch and check for errors using
git apply --check ls *.patch

Then apply the patch with -3way if you want to try every commit nonetheless or go back to editing your patches

git am -3 --sign-off <ls *.patch`

If you use the 3way merge, you can simply ignore and skip deleted file commits and use the log to reprocess all the forgotten files in subsequent patches