genignore builds and maintains a generated block inside your repository's .gitignore.
It detects relevant ignore templates for the current project and environment, fetches merged rules from the Toptal gitignore API, and rewrites only the managed section so the rest of your file stays yours.
- Detects ignore templates from the current directory, one-level non-ignored subdirectories, OS, and installed tools.
- Fans out
detectacrosspackages/*children when apackagesdirectory exists. - Lets you add extra templates explicitly when detection is not enough.
- Keeps provider ordering deterministic so repeated runs stay stable.
- Preserves everything outside the managed markers in
.gitignore. - Supports human-readable output and machine-readable JSON output.
Download the latest archive for your platform from the GitHub Releases page, extract it, and place the genignore binary somewhere on your PATH.
Generate a managed block from automatic detection:
genignore detectPreview changes without writing .gitignore:
genignore detect --dry-runForce specific templates into the detected result:
genignore detect --include node,terraformRemove templates from the detected result:
genignore detect --exclude macos,windowsAppend templates to the existing managed set:
genignore add go nodeList every supported template key:
genignore listSearch supported template keys:
genignore search nodeGet structured output for scripts or CI:
genignore detect --jsonThe tool owns only the block between its markers inside .gitignore.
# BEGIN genignore
# Generated by genignore. Do not edit between these markers.
# Providers: go,node
# generated rules live here
# END genignoreEverything outside that block is preserved on every run.
detect
- Replaces the managed provider set with
detected + include - exclude. - If
./packagesexists and has direct child directories,detectruns per child and writespackages/<child>/.gitignorefor each package. - In
packages/*fanout mode,detectdoes not write a root.gitignore. - Fails if the final provider set is empty.
- Supports
--dry-run,--json, and--verbose.
add <keys...>
- Appends only missing valid providers to the current managed set.
- Keeps existing managed providers intact.
- Always targets only the current directory
.gitignore(nopackages/*fanout). - Supports
--dry-run,--json, and--verbose.
list
- Prints all supported provider keys in deterministic order.
search <term>
- Filters supported provider keys by a search term.
Run the same checks used in CI before pushing changes:
go test ./...
golangci-lint run- The Toptal gitignore API is required at runtime.
- The tool scans the current directory and one level of non-ignored subdirectories.
- If a
packagesdirectory exists,detecttargets each directpackages/*child instead of the root. - Unsupported provider keys are reported as warnings while valid keys still proceed.
- Re-running equivalent commands should not create unnecessary
.gitignorechurn. - Node detection treats
package.json,bun.lock, andbun.lockbas project signals.