git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: "git diff" does not show a diff for newly added, binary files

From
Jeff King <peff@peff.net>
Date
Apr 4, 2023, 15:36 UTC
Message-ID
<20230404153615.GA160693@coredump.intra.peff.net>
In-Reply-To
<2349908.kWcu0K8Tai@earendil>
On Tue, Apr 04, 2023 at 12:39:09PM +0200, Thorsten Otto wrote:
Show 22 quoted lines
> On Dienstag, 4. April 2023 12:17:43 CEST Kristoffer Haugsbakk wrote:
> 
> > Do you use `.gitattributes` to get these binary diffs? What does it look
> > like?
> 
> No, the repo was just created for demonstrating purposes. But when i commit 
> that last change, then do a "git --format-patch -1", i get something like
> 
> diff --git a/b b/b
> new file mode 100644
> index 
> 0000000000000000000000000000000000000000..a64a5a93fb4aef4d5f63d79cb2582731b9ac5063
> GIT binary patch
> literal 512
> NcmZQz7zHCa1ONg600961
> 
> literal 0
> HcmV?d00001
> 
> 
> I would expect "git diff" to output the same information. I don't see a reason 
> why it outputs the diff for a new text file, but not for a binary file?
The behavior you're seeing is expected.

The default for "git diff" is not to show binary patches, because they are often gigantic, and are meaningless to human readers. You can use "--binary" if you want to see them.

The default for "git format-patch" is different, because there the point is to send the patch to somebody to be applied with "git am", so it's important that all information is included.

-Peff
Previous: Kristoffer HaugsbakkNext: Junio C Hamano
Message 7 of 10 in “"git diff" does not show a diff for newly added, binary files”
  1. Thorsten OttoApr 4, 2023
  2. Kristoffer HaugsbakkApr 4, 2023
  3. Thorsten OttoApr 4, 2023
  4. Kristoffer HaugsbakkApr 4, 2023
  5. Thorsten OttoApr 4, 2023
  6. Kristoffer HaugsbakkApr 4, 2023
  7. Jeff KingApr 4, 2023
  8. Junio C HamanoApr 4, 2023
  9. Junio C HamanoApr 4, 2023
  10. Jeff KingApr 4, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.