Reputation: 401
I modified a binary file in test_branch, then, in another branch did:
git diff --full-index --binary test_branch binary_file_name.dat | git apply
However, I get the following error:
error: the patch applies to 'binary_file_name.dat' (e4d7fc486a4ddd1638445449c5bfcec760b23c7f), which does not match the current contents.
error: binary_file_name.dat: patch does not apply
Does anyone know how I can fix the error and apply the binary diff?
Upvotes: 1
Views: 3755
Reputation: 30958
git diff --full-index --binary test_branch binary_file_name.dat
is equivalent to git diff --full-index --binary test_branch HEAD binary_file_name.dat
. The diff means the change that updates binary_file_name.dat
of test_branch
to the binary_file_name.dat
of the other branch (HEAD
). But you are now on the other branch, which means the current binary_file_name.dat
is already the updated version. So swap HEAD
and test_branch
in git diff
and it will work as expected.
git diff --full-index --binary HEAD test_branch binary_file_name.dat | git apply
Upvotes: 3