Gitignore Check

Runs Git's real ignore rules against your files so a .gitignore that only looks right doesn't let secrets or node_modules into a commit.

Stopsnode_modules committed despite .gitignore

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/gitignore-check.json

The files land in your project. They're yours to edit.

Usage

gitignore-check-usage.tsx
import { GitignoreCheck } from "@/components/ui/gitignore-check"

return <GitignoreCheck defaultValue={GITIGNORE} defaultFiles={FILES} trackedFiles={[".env"]} />

What it catches

  • Inline # comments, trailing tabs, leading spaces, backslashes and ./ that change a pattern
  • ! lines that can't re-include a file under an excluded folder, or are overridden later
  • Leading / anchors that miss nested folders
  • .env, private keys or node_modules not ignored
  • Already-committed files .gitignore won't untrack, with the git rm --cached command

Props

GitignoreCheck props
PropTypeDefault
value

Controlled .gitignore text.

string—
defaultValue

Initial .gitignore text when uncontrolled.

string""
onValueChange

Called with the new text on every edit or fix.

(value: string) => void—
files

Controlled file list (one path per line; `git status --porcelain` lines also work).

string—
defaultFiles

Initial file list when uncontrolled.

string""
onFilesChange

Called when the file list is edited.

(files: string) => void—
trackedFiles

Paths you know are committed, e.g. from `git ls-files`.

string[]—
defaultPathsTracked

Start with "These paths are already committed" ticked.

booleanfalse
label

Visible label; shorthand for `messages.label`.

string—
messages

Every visible string. `{line}`, `{detail}`, `{rule}`, `{count}` and friends are filled in.

Partial<GitignoreCheckMessages>—

* required. Also accepts the native props of <textarea> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Text areas have labels; the editor has aria-invalid when errors exist and is described by the status
  • Result summary uses role=status; icons are aria-hidden
  • Each issue has a button to select its line, and focus returns to a sensible control after a fix

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Checks only the one .gitignore and file list you paste; nested .gitignore, .git/info/exclude and global excludes are not read
  • Reimplements Git's rules in JS; edge cases may differ from your Git version
  • Does not scan file contents for secrets

What it stops

node_modules committed despite .gitignore

Also known as

.gitignore · git · ignore file · .env · node_modules · git rm --cached · repo · commit

Field type

Dependencies

Pairs well with