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
Junio C Hamano <gitster@pobox.com>
Date
Apr 4, 2023, 15:42 UTC
Message-ID
<xmqqjzyr3b8e.fsf@gitster.g>
In-Reply-To
<8135fc7b-1953-4702-a9c4-b0f847e69887@app.fastmail.com>
"Kristoffer Haugsbakk" <code@khaugsbakk.name> writes:
Show 7 quoted lines
> On Tue, Apr 4, 2023, at 11:58, Thorsten Otto wrote:
>> "git diff" does not show a diff for newly added, binary files
>> […]
>> I expected a binary diff for the new file, just like it is done
>> when comparing two different, already committed revisions.
>
> Do you use `.gitattributes` to get these binary diffs? What does it look like?
The attribute "binary" can be used like this
    *.mybin	binary

to declare that all files with .mybin suffix are to be treated binary files. "git diff", "git format-patch", etc. will treat such a file as "binary".

What they actually do to "binary files" is a different story. The internal diff machinery by default shows "Binary files A and B differ" just like everybody else's "diff" program does, but has an option to show "binary patch" we invented. "git diff --binary" enables the option, and for some commands, the option is enabled by default.

Previous: Jeff KingNext: Junio C Hamano
Message 8 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.