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

Re: Making git grep ignore binary the default

From
Thomas Braun <thomas.braun@virtuell-zuhause.de>
Date
Oct 17, 2025, 23:29 UTC
Message-ID
<0de410fa-22ef-4495-a6a9-dcd33a329201@virtuell-zuhause.de>
In-Reply-To
<xmqqsefhxlmd.fsf@gitster.g>
Am 17.10.2025 um 23:29 schrieb Junio C Hamano:
Show 24 quoted lines
> El_Hoy <eloyesp@gmail.com> writes:
>
>> I've found that there is a flag (`git grep -I`) to ignore binary
>> files, it works great, but I've found no way to make it the default.
>>
>> It would be great to have a config for this. This way a possible
>> implementation implies:
>>
>> - Adding a config `grep.ignoreBinary` that defaults to false, keeping
>> the current default.
>>
>> - Adding a flag `git grep --include-binary` to revert the default. But
>> maybe the `-a, --text` flag already does that.
>>
>> Also, maybe the next git version (3.0) can default to ignore-binary as
>> a better default.
> I am tempted to suggest not to do any of the above.
>
> Simply because we have never needed to do something similar to "-a"
> and "-I" that we added in early 2006 for the past nearly 20 years.
> Also because GNU does not have any such thing to force "-a" or "-I"
> as default.  The biggest reason is that it would be surprising if
> such a change does not break existing scripts that have been written
> by people over the years.

And if we only would have the config option "grep.ignoreBinary" defaulting to false with no default change whatsoever? I always want to ignore binaries when grepping and find it a bit tedious that I have to spell it out all over again. And yes I do have an alias as well but usually don't remember to use it.

I'm also curious what people are looking for in binary files with git grep.
Previous: Junio C HamanoNext: brian m. carlson
Message 3 of 10 in “Making git grep ignore binary the default”
  1. El_HoyOct 17, 2025
  2. Junio C HamanoOct 17, 2025
  3. Thomas BraunOct 17, 2025
  4. brian m. carlsonOct 18, 2025
  5. Jeff KingOct 18, 2025
  6. rsbecker@nexbridge.comOct 18, 2025
  7. Junio C HamanoOct 18, 2025
  8. Thomas BraunOct 20, 2025
  9. El_HoyOct 20, 2025
  10. Jeff KingOct 21, 2025

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.