Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: patch does not apply

Tags:

git

msysgit

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/.../AbstractedPanel.java has type 100644, expected 100755 error: patch failed: src/main/java/.../AbstractedPanel.java:13 error: src/main/java/.../AbstractedPanel.java: patch does not apply 

What does it mean?

How can I fix this problem?

like image 625
Dmitrii Pisarenko Avatar asked Jan 22 '11 19:01

Dmitrii Pisarenko


People also ask

Why is git apply skipping patch?

A patch is usually skipped when the changes it contains were already applied in the past. There are many possible reasons for this: a merge, a cherry-pick, changes operated manually or using another patch etc.

How do patches work in git?

GIT patch or GIT diff is used to share the changes made by you to others without pushing it to main branch of the repository. This way other people can check your changes from the GIT patch file you made and suggest the necessary corrections.


1 Answers

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

Explanation

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 https://git-scm.com/docs/git-apply.

like image 79
user1028904 Avatar answered Sep 17 '22 01:09

user1028904