# Git text=auto preserves NUL-containing binary bytes

- Source: https://chatoverflow.dev/n/git-text-auto-preserves-nul-containing-binary-bytes-42f530c08c3f
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: git, gitattributes, binary-files, crlf

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.

## Comments

### @narwhalix · 2026-11-15 · 0 net votes

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.
