@sulthonzh/git-ignore-gen
v1.1.0
Published
Interactive CLI that scans your project for untracked files and suggests .gitignore patterns based on actual project state
Maintainers
Readme
git-ignore-gen
Interactive CLI that scans your project for untracked files and suggests .gitignore patterns based on actual project state.
Features
- Project-aware scanning: Analyzes
git statusto identify untracked files - Smart pattern detection: Suggests ignore rules based on file extensions, naming patterns, and directory structures
- Interactive selection: Presents detected patterns with explanations and allows selective inclusion
- High confidence matching: Uses pattern recognition with confidence scoring
- Category grouping: Organizes patterns by type (dependencies, build, logs, system, etc.)
- Safe operations: Supports dry-run mode and update mode to preserve existing .gitignore
- Enhanced pattern support: Now includes patterns for Python, Java, IDE files, and more frameworks
Installation
npm install -g git-ignore-genOr run directly with npx:
npx git-ignore-genUsage
Basic Usage
Scan your current directory and show suggested patterns:
git-ignore-genInteractive Mode
Select which patterns to include interactively:
git-ignore-gen --interactiveUpdate Existing .gitignore
Add new patterns to an existing .gitignore file:
git-ignore-gen --updateDry Run
Preview suggestions without writing files:
git-ignore-gen --dry-runCustom Path
Scan a specific repository:
git-ignore-gen --path /path/to/repoExample Output
🔍 Checking git repository...
✓ Git repository detected
✓ Found 15 untracked files
✓ Detected 6 potential patterns
📋 Detected Patterns:
node_modules/
Node.js dependencies directory
Confidence: [██████████] 95%
Examples: node_modules/lodash/, node_modules/react/
*.log
Log files
Confidence: [████████░░] 85%
Examples: error.log, debug.log
dist/
Distribution build directory
Confidence: [████████░░] 88%
Examples: dist/bundle.js, dist/index.html
✅ Added 6 patterns to .gitignoreHow It Works
- Scans git status: Reads untracked files from your repository
- Detects patterns: Matches files against common ignore patterns
- Scores confidence: Ranks patterns based on match frequency
- Generates .gitignore: Creates organized, commented .gitignore file
Supported Patterns
The tool recognizes common patterns for:
- Dependencies:
node_modules/,vendor/,venv/,.venv/ - Build artifacts:
dist/,build/,.next/,.nuxt/,target/,__pycache__/,*.pyc - Logs:
*.log,npm-debug.log*,yarn-debug.log*,yarn-error.log* - System files:
.DS_Store,Thumbs.db,.idea/,.vscode/ - Config:
.env.local - Test coverage:
coverage/ - Cache:
.cache/ - IDE files: IntelliJ IDEA, VS Code, Sublime Text project files
- Python: Virtual environments, bytecode cache, compiled files
- Java: Gradle build system files
- Web frameworks: Next.js, Nuxt.js, Jekyll, SASS
Options
Usage: git-ignore-gen [options]
Options:
-i, --interactive Interactive mode with pattern selection
-u, --update Update existing .gitignore instead of overwriting
-d, --dry-run Show suggestions without writing files
-p, --path <path> Path to git repository (default: current directory)
-h, --help Display help
-V, --version Display versionUse Cases
- New projects: Quickly create comprehensive .gitignore files
- Forgotten patterns: Detect files that should have been ignored
- Code review: Ensure proper git hygiene before commits
- Template augmentation: Enhance existing .gitignore with project-specific patterns
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT
Author
sulthonzh
