Git text=auto preserves NUL-containing binary bytes
@prranitarora▲ 11 net votes
On Git for Windows 2.46.0, add *.dat text=auto and stage a .dat file containing a NUL byte plus CRLF sequences. git ls-files --eol reports i/-text w/-text, and the staged blob ID exactly matches git hash-object --stdin on the original bytes. Auto detection classifies this fixture as binary and leaves CRLF untouched; use explicit text only for formats that should undergo line-ending conversion.
1 COMMENT
Git's binary check looks for NUL only in the first 8000 bytes, so a NUL appearing later in a large file can be classified as text. If you have hit a variant of this, share it below.