# .gitignore tester

Check which paths a .gitignore file ignores and which line decided each one, using real Git matching rules.

- Endpoint: `POST https://setget.net/v1/tools/gitignore-test` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `gitignore-test`
- Page: https://setget.net/tools/gitignore-test

## Inputs

- `gitignore` (required, string): The contents of the .gitignore file.
- `paths` (required, array): Paths relative to the folder holding the .gitignore. End a path with / to mark it as a folder.

## Example 1

```json
{"input":{"gitignore":"# logs and build output\n*.log\n/build/\n!important.log\ndocs/**/*.tmp","paths":["debug.log","important.log","build/app.js","src/build/app.js","docs/a/b/x.tmp"]}}
```

Result:

```json
{"results":[{"path":"debug.log","ignored":true,"line":2,"pattern":"*.log"},{"path":"important.log","ignored":false,"line":4,"pattern":"!important.log"},{"path":"build/app.js","ignored":true,"line":3,"pattern":"/build/"},{"path":"src/build/app.js","ignored":false,"line":null,"pattern":null},{"path":"docs/a/b/x.tmp","ignored":true,"line":5,"pattern":"docs/**/*.tmp"}],"ignored":["debug.log","build/app.js","docs/a/b/x.tmp"],"not_ignored":["important.log","src/build/app.js"]}
```

## Example 2: Ignore everything except one folder (from the Git manual)

```json
{"input":{"gitignore":"/*\n!/foo\n/foo/*\n!/foo/bar","paths":["readme.md","foo/baz.txt","foo/bar/x.txt"]}}
```

Result:

```json
{"results":[{"path":"readme.md","ignored":true,"line":1,"pattern":"/*"},{"path":"foo/baz.txt","ignored":true,"line":3,"pattern":"/foo/*"},{"path":"foo/bar/x.txt","ignored":false,"line":4,"pattern":"!/foo/bar"}],"ignored":["readme.md","foo/baz.txt"],"not_ignored":["foo/bar/x.txt"]}
```

**Why does my "!" rule not bring a file back?** Git does not look inside an ignored folder, so a file cannot be re-included when one of its parent folders is ignored. Un-ignore the folder first.

**When is a pattern tied to the top folder?** When it has a slash at the start or in the middle. A pattern without one, such as *.log, matches at any depth.

**How do I say that a path is a folder?** End it with a slash. Patterns that end with a slash match folders only.

**Are files already tracked by Git affected?** No. Ignore rules apply only to untracked files. This tool cannot see your repository.
