Git apply patch line ending

Git patch files can be generated like:

git diff > my.patch

If the Git patch file is generated on a Windows computer and is copied to a non-Windows computer, the patch may fail to “git apply my.patch” on the non-Windows computer. If the mismatches seen with “git apply my.patch -v” show question marks “?” at the end of each line, the issue may simply be line endings mismatch.

Try fixing line endings in the patch file using dos2unix on the computer where the patch is to be applied:

dos2unix my.patch
git apply my.patch

dos2unix is installed like “brew install dos2unix” or “apt install dos2unix” or similar.