> 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`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.eliasnorrby.com/git/remove-file-from-diff.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
