Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git cannot apply binary patch *** without full index line

Tags:

git

When I try to apply a patch from a file, I see

error: cannot apply binary patch to 'my/resource.png' without full index line
error: my/resource.png: patch does not apply

I added my/resource.png in the commit from which I made the patch. How can I enabled full-index support?

like image 677
Rose Perrone Avatar asked Jun 17 '13 16:06

Rose Perrone


2 Answers

Checkout the branch from which you want to create the patch. Run this command:

git diff-index 79fd4d7 --binary > ~/Desktop/my-patch

Where 79fd4d7 is a placeholder for the commit that came right before the range of commits you want to diff. (e.g. I want a patch that contains the first three commits below:

aaa02b0 third commit mine
aabbbcc second commit mine
bb82aed first commit mine
79fd4d7 old commit

Then checkout your new branch and run git apply ~/Desktop/my-patch

like image 72
Rose Perrone Avatar answered Sep 25 '22 05:09

Rose Perrone


I want to post another way if you have only deleted some files and get the same message. Because I didn't had access to the source code anymore (through reset to another commit), I needed another solution (instead of creating a new patch file).

Therefore I deleted the following parts from my patch file:

diff --git a/MyProject/Libraries/some.dll b/MyProject/Libraries/some.dll
deleted file mode 100644
index a0908d7..0000000
Binary files a/MyProject/Libraries/some.dll and /dev/null differ
diff --git a/MyProject/Libraries/some.dll.mdb b/MyProject/Libraries/some.dll.mdb
deleted file mode 100644
index d3c3912..0000000
Binary files a/MyProject/Libraries/some.dll.mdb and /dev/null differ

Afterwards I could apply my patch file with success! Don't know why he wants to make a binary compare on a deleted file ...

like image 25
testing Avatar answered Sep 21 '22 05:09

testing