git: patch does not apply


I have a certain patch called my_pcc_branch.patch.

When I try to apply it, I get following message:

$ git apply --check my_pcc_branch.patch
warning: src/main/java/.../ has type 100644, expected 100755
error: patch failed: src/main/java/.../
error: src/main/java/.../ patch does not apply

What does it mean?

How can I fix this problem?


git apply --reject --whitespace=fix mychanges.patch worked for me.


The --reject option will instruct git to not fail if it cannot determine how to apply a patch, but instead to apply the individual hunks it can apply and create reject files (.rej) for hunks it cannot apply. Wiggle can "apply [these] rejected patches and perform word-wise diffs".

Additionally, --whitespace=fix will warn about whitespace errors and try to fix them, rather than refusing to apply an otherwise applicable hunk.

Both options together make the application of a patch more robust against failure, but they require additional attention with respect to the result.

For the whole documentation, see

How do I revert a merge commit that has already been pushed to remote?

How can I keep my fork in sync without adding a separate remote?