Skip to content

aaronflorey/genignore

Repository files navigation

genignore

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.

What It Does

  • Detects ignore templates from the current directory, one-level non-ignored subdirectories, OS, and installed tools.
  • Fans out detect across packages/* children when a packages directory 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.

Install

Download the latest archive for your platform from the GitHub Releases page, extract it, and place the genignore binary somewhere on your PATH.

Quick Start

Generate a managed block from automatic detection:

genignore detect

Preview changes without writing .gitignore:

genignore detect --dry-run

Force specific templates into the detected result:

genignore detect --include node,terraform

Remove templates from the detected result:

genignore detect --exclude macos,windows

Append templates to the existing managed set:

genignore add go node

List every supported template key:

genignore list

Search supported template keys:

genignore search node

Get structured output for scripts or CI:

genignore detect --json

How Managed Updates Work

The 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 genignore

Everything outside that block is preserved on every run.

Command Guide

detect

  • Replaces the managed provider set with detected + include - exclude.
  • If ./packages exists and has direct child directories, detect runs per child and writes packages/<child>/.gitignore for each package.
  • In packages/* fanout mode, detect does 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 (no packages/* 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.

Development checks

Run the same checks used in CI before pushing changes:

go test ./...
golangci-lint run

Notes

  • The Toptal gitignore API is required at runtime.
  • The tool scans the current directory and one level of non-ignored subdirectories.
  • If a packages directory exists, detect targets each direct packages/* 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 .gitignore churn.
  • Node detection treats package.json, bun.lock, and bun.lockb as project signals.

About

CLI that generates and maintains the managed section of a repository's .gitignore.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages