How do I know if a diff in git is a binary add / remove?

My diff looks like this:

--- a/binarytest copy.png
+++ /dev/null
@@ -1,863 +0,0 @@\n-8950 4e47 0d0a 1a0a 0000 000d 4948 4452
-0000 00c8 0000 00c8 0803 0000 009a 865e
-ac00 0000 0970 4859 7300 000b 1300 000b
-1301 009a 9c18 0000 0a4f 6943 4350 5068
-6f74 6f73 686f 7020 4943 4320 7072 6f66
-696c 6500 0078 da9d 5367 5453 e916 3df7
-def4 424b 8880 944b 6f52 1508 2052 428b
-8014 9126 2a21 0910....

      

It is basically deleting the binary. How can I parse this so that I always know the binary has been deleted?

I am trying to check if it was a remote binary as opposed to a text file. Is it possible?

+3


source to share


1 answer


I just did some simple checks.

When I added the remote binary and then did git diff HEAD^

, I get the results like this:

diff --git a/junk.bin b/junk.bin
deleted file mode 100644
index 0a3970d..0000000
Binary files a/junk.bin and /dev/null differ

      



When I removed the non binary and did the same git diff HEAD^

, I get the following results:

diff --git a/text.txt b/text.txt
deleted file mode 100644
index a496efe..0000000
--- a/text.txt
+++ /dev/null
@@ -1 +0,0 @@
-This is a text file

      

My suggestion is to use the git diff

VS straight command diff

. Git will tell you if it was a binary file or not directly in its diff (i.e. no "deleted" text ... just a deleted file).

+2


source







All Articles