---
title: "The .lootignore file"
url: https://docs.loot.build/reference/lootignore
group: "Reference"
status: written
summary: "Patterns, and the deliberate absence of negation."
---

# The .lootignore file

> Patterns, and the deliberate absence of negation.

`.lootignore` lists paths loot never captures. It uses the [`.lootattributes`](https://docs.loot.build/reference/lootattributes) pattern dialect, one pattern per line, and has no negation.

```bash
# build output
target/
node_modules/
**/node_modules/
**.log
```

## Lines

- Each line is one pattern: the whole line with its ends trimmed, spaces inside included.
- A line starting with `#` is a comment, and blank lines are skipped.
- Patterns match the whole path from the repo root. `*` stops at `/`, `**` crosses it, every other character is literal, and matching is case-sensitive.
- A trailing `/` means the subtree: `target/` is `target/**`. loot skips such a directory without walking it.

| Pattern | Ignores | Does not ignore |
| --- | --- | --- |
| `*.log` | `debug.log` | `logs/debug.log` |
| `**.log` | `debug.log`, `logs/a/debug.log` | `debug.LOG` |
| `target/` | `target/debug/app` | `crates/x/target/a` |
| `**/node_modules/` | `web/node_modules/x` | `node_modules/x` |

A directory at the root and the same name below it are two patterns, which is why the example lists `node_modules/` and `**/node_modules/`.

## No negation

A line starting with `!` does not un-ignore anything. It is a literal pattern for a file named `!…`, and loot prints a warning when it reads one. This is deliberate: if a later line could bring a path back, loot could no longer skip a whole directory without walking it. To keep a file, narrow the broad pattern so it no longer covers that file.

## Encoding

Save the file as UTF-8 without a byte-order mark. loot stops with an error when it is anything else, since it could not read the lines as written. Windows PowerShell 5.1's `>` writes UTF-16; `Set-Content -Encoding ascii` writes a file loot reads. `loot ferry` takes in a git commit carrying such a file, whoever wrote it, with no ignore rules and a warning.

## What it never ignores

- `.lootattributes` and `.lootignore` themselves. They stay versioned so the rules travel.
- `.loot/`, which the walk skips before any rule runs, so it needs no line.

loot does not read `.gitignore`.

## Ignoring a path that is already recorded

The next capture records it as deleted from the working change. The file stays on your disk. `loot explain <path>` names the line that ignores a path, and `loot clean -X` lists the ignored files no change records (add `--force` to delete them).
