> For the complete documentation index, see [llms.txt](https://notes.eliasnorrby.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.eliasnorrby.com/git/remove-file-from-diff.md).

# Hide file from git diff output

`git diff` will show patches for text files, but not for binary files, like images, because the output is not likely to make any sense. Some checked in text files, like `package-lock.json`, can be considered binary too: while technically composed of text characters, it's opaque to a human reader. In addition to that, it's diff output long, and commonly fills the entire screen when running `git diff`. To avoid this, we can mark the file as binary by unsetting the diff attribute in `.gitattributes`:

```
package-lock.json -diff
```

Source: `LESS='-p Marking files as binary' man gitattributes`
