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

Re: Making git grep ignore binary the default

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Oct 18, 2025, 00:52 UTC
Message-ID
<aPLkuPgirAVHkERr@fruit.crustytoothpaste.net>
In-Reply-To
<0de410fa-22ef-4495-a6a9-dcd33a329201@virtuell-zuhause.de>
On 2025-10-17 at 23:29:22, Thomas Braun wrote:
Show 13 quoted lines
> Am 17.10.2025 um 23:29 schrieb Junio C Hamano:
> > 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.

As Junio said, this could break existing scripts. If I write a command which uses `git grep` and expects to find all matching files, it would not work on your system with `grep.ignoreBinary` set to true.

For instance, if I am working on a project for a company and must exclude source code with a certain vendor's copyright (because we don't have permission to distribute their code), then it would be very bad if I accidentally distributed that company's binary files due to `git grep -l PATTERN | xargs rm -f` not matching them since it would violate the license.

This is just an example, but there are lots of cases where people do really want to search every file.

> I'm also curious what people are looking for in binary files with git grep.

It's common to mark PDFs or PostScript files as binary because they often contain embedded binary fonts, but they are actually mostly text and can be usefully searched with grep. For instance, I once created some awards for a non-profit based on combining standalone text-based PostScript code along with output from groff, so those independent pieces could end up being source that you might store in Git and search, even if many configurations would use `*.ps -text` in a system gitattributes file.

Sometimes you also have images or such for a website, which contain XMP metadata (a form of XML-serialized RDF). Finding those images which have certain author metadata or a certain license URL embedded in them could be valuable.

-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Previous: Thomas BraunNext: rsbecker@nexbridge.com
Message 4 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. rsbecker@nexbridge.comOct 18, 2025
  6. Thomas BraunOct 20, 2025
  7. El_HoyOct 20, 2025
  8. Jeff KingOct 21, 2025
  9. Jeff KingOct 18, 2025
  10. Junio C HamanoOct 18, 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.