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

前端 未结 2 1492
逝去的感伤
逝去的感伤 2020-12-13 08:13

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          


        
相关标签:
2条回答
  • 2020-12-13 08:59

    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

    0 讨论(0)
  • 2020-12-13 09:04

    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 ...

    0 讨论(0)
提交回复
热议问题