gritHEAD → docs/ignore
Commands / PlumbingMarkdown

grit ignore

Query whether paths match exclude (gitignore) rules.

grit ignore check <PATH>...
grit ignore check --all <PATH>...

Description

The check subcommand reports whether paths are ignored by .gitignore, .git/info/exclude, and core.excludesfile, using the same precedence as Git. Tracked index entries are never treated as ignored. When core.ignorecase is true (grit init sets it on case-insensitive filesystems, such as the Windows and macOS defaults), patterns match without regard to ASCII case, as in Git: Build/ ignores build/x.o and *.LOG ignores debug.log. grit status, grit add, grit commit and grit clean use the same rules.

By default only ignored paths are printed. Pass --all to also list paths that are not ignored.

Paths are resolved from the current directory and normalized within the worktree. They do not need to exist; a trailing / marks a directory query. Batch queries reuse the resolved worktree root when normalizing paths.

The command exits with status 0 when at least one path is ignored, and 1 when none are. Scripts can branch on this exit code.

Human output uses a verbose-style line per ignored path:

path  ← .gitignore:3 *.log

Options

Option Description
--all Also print paths that are not ignored.
<PATH> One or more paths (from the current directory or repository-relative).

JSON output

Schema: v1

Pass --json for stable, scripting-friendly output:

Field Type Meaning
any_ignored boolean true when at least one queried path is ignored.
entries array Filtered results (ignored only unless --all).
entries[].path string Repository-relative path.
entries[].ignored boolean Whether the path is ignored.
entries[].matched object or omitted Verbose match metadata when present.
entries[].matched.source object Typed source (per_directory, info_exclude, or core_excludes_file).
entries[].matched.line_number number 1-based line in the source file.
entries[].matched.pattern_text string Pattern text as written in the file.
entries[].matched.negative boolean Whether the rule is negated (!pattern).

Markdown output

Schema: v1

Pass --markdown for agent-friendly output with the same fields summarized in prose and lists.

Exit status

Code Meaning
0 At least one path is ignored (ignore check).
1 No matching ignored paths.
2 Invalid flags (usage).

See Exit codes.