tags:

views:

166

answers:

3

Hi,

Can you please tell me how can I resolve the 'patch does not apply' error when I try to 'git apply-patch'?

$ git apply 0001-my.patch
error: patch failed:test.xml:114
error: text.xml: patch does not apply

I do have 'test.xml' in my local directory. And when I do 'git status', it shows I don't have local changes.

Thank you for any help.

A: 

Well, the patch has information about what should be change to what. If the first what doesn't match file contents, the patch doesn't apply.

Michael Krelin - hacker
+1  A: 

You can try a:

git am -3

When the patch does not apply cleanly, fall back on 3-way merge (git am doc)

VonC
A: 

Or you may also want to rebase with main or origin

git rebase origin

Just to make sure you are on the same track with latest changes before you will start applying patches from other guys.

Kuznero