Skip to main content

A magical CLI tool that automatically generates and manages .gitignore files

Project description

โœจ gitignore-gen

A magical CLI tool that automatically generates and manages .gitignore files for your projects. Simply run it in any directory and watch as it intelligently detects your project's technologies and creates the perfect .gitignore file.

Author: Sherin Joseph Roy
Email: sherin.joseph2217@gmail.com
Repository: https://github.com/Sherin-SEF-AI/gitignore-gen

๐Ÿš€ Features

  • ๐Ÿ” Smart Detection: Automatically detects 50+ technologies including Python, Node.js, Java, Go, Rust, Swift, Unity, VS Code, JetBrains IDEs, and many more
  • ๐ŸŒ API Integration: Fetches templates from gitignore.io with intelligent caching
  • ๐Ÿ”„ Smart Merging: Combines multiple templates and removes duplicates
  • ๐Ÿ›ก๏ธ Security Patterns: Optional security-focused patterns for API keys, certificates, and secrets
  • ๐Ÿ“ Monorepo Support: Generate per-directory .gitignore files for complex projects
  • ๐Ÿ’พ Backup & Safety: Automatic backups and dry-run mode for safe experimentation
  • ๐ŸŽจ Beautiful UI: Rich terminal output with progress bars, colors, and emojis
  • โšก Performance: Async operations for fast scanning and template fetching
  • ๐Ÿ”ง Advanced Analysis: Comprehensive project analysis with dependency scanning, security checks, and performance insights
  • ๐Ÿ“Š Interactive Recommendations: Get actionable suggestions based on your project structure
  • ๐Ÿ”„ Real-time Monitoring: Watch mode for automatic updates when files change
  • ๐Ÿ“ฆ Custom Templates: Create, manage, and share your own templates
  • ๐Ÿ› ๏ธ Auto-fix: Automatically remove tracked files that should be ignored

๐Ÿ“ฆ Installation

From PyPI (Recommended)

pip install gitignore-gen

From Source

git clone https://github.com/Sherin-SEF-AI/gitignore-gen.git
cd gitignore-gen
pip install -e .

Development Installation

git clone https://github.com/Sherin-SEF-AI/gitignore-gen.git
cd gitignore-gen
pip install -e ".[dev]"

๐ŸŽฏ Quick Start

Basic Usage

Simply run gitignore-gen in your project directory:

cd your-project
gitignore-gen

The tool will:

  1. ๐Ÿ” Scan your project for technologies
  2. ๐Ÿš€ Fetch appropriate templates
  3. ๐Ÿ”„ Merge and optimize the content
  4. ๐Ÿ’พ Save a perfect .gitignore file

Interactive Mode

For more control, use interactive mode:

gitignore-gen --interactive

This will let you:

  • Choose which templates to include
  • Add custom templates
  • Preview changes before applying

๐Ÿ“š Complete Command Reference

Main Commands

gitignore-gen - Main Generation

Generate a .gitignore file for the current directory.

# Basic generation
gitignore-gen

# With options
gitignore-gen --security --backup --dry-run

# Interactive mode
gitignore-gen --interactive

# Minimal mode for cleaner output
gitignore-gen --minimal

# Strict mode for precise patterns
gitignore-gen --strict

Options:

  • --verbose, -v: Enable verbose output
  • --quiet, -q: Suppress all output except errors
  • --dry-run: Preview changes without applying them
  • --interactive, -i: Enable interactive mode
  • --backup: Create backup of existing .gitignore
  • --security: Add common security patterns
  • --monorepo: Generate per-directory .gitignore files
  • --auto-fix: Automatically remove files that should be ignored from git
  • --watch: Watch for file changes and auto-update .gitignore
  • --export PATH: Export current .gitignore configuration
  • --import PATH: Import .gitignore configuration
  • --custom-templates PATH: Path to custom templates directory
  • --force: Force overwrite existing .gitignore
  • --minimal: Generate minimal .gitignore with only essential patterns
  • --strict: Use strict pattern matching for better accuracy

gitignore-gen scan - Technology Detection

Scan directory and detect technologies in use.

# Scan current directory
gitignore-gen scan

# Scan specific path
gitignore-gen scan --path /path/to/project

gitignore-gen version - Version Information

Show version information.

gitignore-gen version

Template Management

gitignore-gen list-templates - List Templates

List available templates (built-in and custom).

# List all templates
gitignore-gen list-templates

# Search for specific templates
gitignore-gen list-templates --template python

# Show only custom templates
gitignore-gen list-templates --custom-only

gitignore-gen templates - Show Template Content

Show content of a specific template.

# Show Python template
gitignore-gen templates --template python

# Save template to file
gitignore-gen templates --template node --output node.gitignore

gitignore-gen create-template - Create Custom Template

Create a custom template.

# Create from content
gitignore-gen create-template --template myproject --content "*.log\n*.tmp"

# Create from file
gitignore-gen create-template --template myproject --file template.txt

gitignore-gen update-template - Update Template

Update an existing custom template.

# Update with new content
gitignore-gen update-template --template myproject --content "*.log\n*.tmp\n*.cache"

# Update from file
gitignore-gen update-template --template myproject --file new-template.txt

gitignore-gen delete-template - Delete Template

Delete a custom template.

# Delete with confirmation
gitignore-gen delete-template --template myproject

# Force delete without confirmation
gitignore-gen delete-template --template myproject --force

gitignore-gen search-templates - Search Templates

Search for templates by name or content.

# Search by name
gitignore-gen search-templates --query python

# Search only custom templates
gitignore-gen search-templates --query myproject --custom-only

Project Analysis

gitignore-gen analyze - Project Analysis

Analyze project structure and generate detailed report.

# Analyze current directory
gitignore-gen analyze

# Analyze specific path
gitignore-gen analyze --path /path/to/project

# Save report to file
gitignore-gen analyze --output analysis_report.json

gitignore-gen scan-dependencies - Dependency Scanning

Scan project dependencies and generate detailed report.

# Scan current directory
gitignore-gen scan-dependencies

# Save as JSON
gitignore-gen scan-dependencies --output deps.json

# Save as YAML
gitignore-gen scan-dependencies --output deps.yaml --format yaml

# Save as CSV
gitignore-gen scan-dependencies --output deps.csv --format csv

gitignore-gen performance-insights - Performance Analysis

Generate performance insights and optimization recommendations.

# Analyze current directory
gitignore-gen performance-insights

# Custom threshold (default: 10MB)
gitignore-gen performance-insights --threshold 50

# Save report
gitignore-gen performance-insights --output perf_report.json

gitignore-gen security-scan - Security Analysis

Perform comprehensive security scan and generate report.

# Full security scan
gitignore-gen security-scan

# Specific severity level
gitignore-gen security-scan --severity high

# Save report
gitignore-gen security-scan --output security_report.json

Advanced Features

gitignore-gen monorepo-setup - Monorepo Configuration

Set up comprehensive .gitignore structure for monorepos.

# Basic setup
gitignore-gen monorepo-setup

# With shared patterns
gitignore-gen monorepo-setup --shared

# Generate per-service files
gitignore-gen monorepo-setup --per-service

# Specific strategy
gitignore-gen monorepo-setup --strategy nested

Strategies:

  • flat: Simple flat structure
  • nested: Nested directory structure
  • hybrid: Mixed approach (default)

gitignore-gen optimize - .gitignore Optimization

Optimize existing .gitignore file for better performance.

# Preview optimizations
gitignore-gen optimize --dry-run

# Apply optimizations
gitignore-gen optimize

# Aggressive optimization
gitignore-gen optimize --aggressive

gitignore-gen auto-fix - Auto-fix Tracked Files

Automatically remove files that should be ignored from git.

# Preview what would be fixed
gitignore-gen auto-fix --dry-run

# Apply fixes
gitignore-gen auto-fix

gitignore-gen clean - Clean Ignored Files

Clean up files that should be ignored from git.

# Preview cleanup
gitignore-gen clean --dry-run

# Apply cleanup
gitignore-gen clean

gitignore-gen watch - File Watching

Watch for file changes and auto-update .gitignore.

# Watch current directory
gitignore-gen watch

# Custom interval (default: 5 seconds)
gitignore-gen watch --interval 10

# Watch specific path
gitignore-gen watch --path /path/to/project

Configuration Management

gitignore-gen export-config - Export Configuration

Export .gitignore and detected technologies to a config file.

# Export to default location
gitignore-gen export-config

# Export to specific file
gitignore-gen export-config --output my-config.json

gitignore-gen import-config - Import Configuration

Import a .gitignore-gen config and regenerate .gitignore.

# Import from file
gitignore-gen import-config --config my-config.json

# Import to specific location
gitignore-gen import-config --config my-config.json --output .gitignore

๐ŸŽจ Supported Technologies

Programming Languages

  • Python (Django, Flask, FastAPI, Jupyter)
  • Node.js (React, Vue, Angular, Express)
  • Java (Spring, Maven, Gradle, Android)
  • Go (Go modules, Go workspaces)
  • Rust (Cargo, Rust projects)
  • Swift (iOS, macOS development)
  • C# (.NET, Unity, Xamarin)
  • PHP (Laravel, WordPress, Composer)
  • Ruby (Rails, Bundler, RVM)
  • Dart (Flutter, Dart projects)
  • Kotlin (Android, JVM)
  • Scala (SBT, Scala projects)

Frameworks & Libraries

  • Frontend: React, Vue, Angular, Svelte, Next.js, Nuxt.js
  • Backend: Django, Flask, FastAPI, Express, Spring, Laravel
  • Mobile: Flutter, React Native, Ionic
  • Desktop: Electron, Tauri, PyQt, Tkinter

Build Tools & Package Managers

  • JavaScript: npm, yarn, pnpm, webpack, vite, rollup
  • Python: pip, poetry, pipenv, conda
  • Java: Maven, Gradle, Ant
  • Go: go mod, go work
  • Rust: Cargo, Cargo workspaces

IDEs & Editors

  • VS Code (.vscode, settings, extensions)
  • JetBrains (IntelliJ IDEA, PyCharm, WebStorm, Android Studio)
  • Eclipse (.metadata, .project, .classpath)
  • Vim/Neovim (.vim, .nvim, swap files)
  • Emacs (.emacs, .emacs.d)

Operating Systems

  • macOS (.DS_Store, Spotlight, Time Machine)
  • Windows (Thumbs.db, desktop.ini, Recycle Bin)
  • Linux (core dumps, temporary files)

Cloud & DevOps

  • Docker (Dockerfile, docker-compose, .dockerignore)
  • Kubernetes (k8s manifests, helm charts)
  • Terraform (.tfstate, .tfvars, modules)
  • Ansible (playbooks, inventory, roles)
  • Jenkins (workspace, builds, logs)

Version Control

  • Git (.git, .gitignore, .gitattributes)
  • GitHub (GitHub Actions, .github)
  • GitLab (GitLab CI, .gitlab-ci.yml)

Testing & Quality

  • Jest (coverage, snapshots)
  • Cypress (videos, screenshots)
  • Playwright (test-results, playwright-report)
  • Pytest (.pytest_cache, coverage)
  • Coverage (htmlcov, .coverage)

๐Ÿ”ง Configuration

Create a configuration file at ~/.gitignore-gen.toml:

[api]
base_url = "https://www.tgitignore.io/api"
timeout = 30

[cache]
enabled = true
ttl = 86400  # 24 hours

[security]
auto_add = false
patterns = [
    "*.key",
    "*.pem",
    "*.env"
]

[detection]
scan_depth = 3
ignore_dirs = [".git", "node_modules", "venv"]

๐Ÿงช Examples

Python Project

$ gitignore-gen
๐Ÿ” Scanning project...
๐Ÿš€ Generating .gitignore...
๐Ÿ’พ Saving .gitignore...

โœ… .gitignore generated successfully!

Detected technologies:
โ€ข python
โ€ข vscode

React + Node.js Project

$ gitignore-gen --interactive
๐Ÿ” Scanning project...
๐ŸŽฏ Template Selection:
Include python template? [y/N]: n
Include node template? [y/N]: y
Include react template? [y/N]: y
Include vscode template? [y/N]: y

๐Ÿ“‹ Generated .gitignore Preview:
# Generated by gitignore-gen
# Technologies detected: node, react, vscode

node_modules/
.env
dist/
build/
.vscode/
*.log
...

Apply this .gitignore? [y/N]: y
โœ… .gitignore generated successfully!

Monorepo with Security

$ gitignore-gen --monorepo --security --backup
๐Ÿ” Scanning project...
๐Ÿš€ Generating .gitignore...
๐Ÿ’พ Saving .gitignore...

โœ… .gitignore generated successfully!
๐Ÿ“ Created per-directory .gitignore files
๐Ÿ”’ Added security patterns
๐Ÿ’พ Backup created: .gitignore.backup

Advanced Analysis

$ gitignore-gen analyze --output report.json
๐Ÿ” Analyzing project: /path/to/project

๐Ÿ“Š Project Analysis Results

๐Ÿ”ง Detected Technologies:
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Technology โ”ƒ Confidence โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ python     โ”‚ 100.0%     โ”‚
โ”‚ node       โ”‚ 30.0%      โ”‚
โ”‚ docker     โ”‚ 10.0%      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ Dependencies:
  โ€ข python: pyproject.toml

๐Ÿ—๏ธ Project Structure:
  โ€ข Type: desktop
  โ€ข Depth: 8 levels

๐Ÿ“ˆ File Statistics:
  โ€ข Total files: 1250
  โ€ข Total directories: 45

๐Ÿ”’ Security Analysis:
  โ€ข โš ๏ธ Sensitive files found: 3
  โ€ข Recommendations:
    - Ensure .env files are in .gitignore

โšก Performance Analysis:
  โ€ข โš ๏ธ Deep directory nesting detected
  โ€ข Recommendations:
    - Consider flattening directory structure

๐Ÿ’ก Recommendations:
  1. Consider adding __pycache__/ and *.pyc to .gitignore
  2. Ensure node_modules/ is in .gitignore
  3. Ensure .env files are in .gitignore

โœ… Report saved to: report.json

Custom Template Management

# Create a custom template
$ gitignore-gen create-template --template myproject --content "*.log\n*.tmp\n.env.local"

# List templates (custom template will show with โœ“)
$ gitignore-gen list-templates
๐Ÿ“š Available Templates:
Custom (1): myproject
Built-in (32): python, node, java, go, rust, php, ruby, csharp, swift, kotlin, scala, dart, flutter, react, vue, angular, svelte, docker, kubernetes, terraform, ansible, jenkins, github, gitlab, vscode, intellij, eclipse, vim, emacs, macos, windows, linux
  โœ“ myproject
  โ— python
  โ— node
  ...

# Search for templates
$ gitignore-gen search-templates --query myproject
๐Ÿ” Search Results for "myproject":
  โœ“ myproject (custom template)

Performance Optimization

$ gitignore-gen optimize --dry-run
โšก Optimizing .gitignore in: /path/to/project
Original .gitignore: 150 lines

๐Ÿ” Optimization Analysis:
  โ€ข Duplicate patterns: 5
    Line 145: .coverage
    Line 146: htmlcov/
    Line 147: .pytest_cache/
  โ€ข Redundant patterns: 2
    Line 140: .cache/
  โ€ข Inefficient patterns: 1
    Line 25: *.egg-info/

Potential optimization: Remove 8 lines
Dry run mode - no changes applied

Security Scanning

$ gitignore-gen security-scan --severity high
๐Ÿ”’ Performing security scan in: /path/to/project
Severity level: high

๐Ÿ”’ Security Analysis Results:
  โ€ข โš ๏ธ Sensitive files found: 5
    - /path/to/project/.env
    - /path/to/project/config/private.key
    - /path/to/project/secrets/database.yml
    - /path/to/project/certificates/server.crt
    - /path/to/project/.aws/credentials

๐Ÿ’ก Security Recommendations:
  1. Ensure .env files are in .gitignore
  2. Add *.key and *.pem to .gitignore
  3. Consider using environment variables for secrets
  4. Review certificate files for sensitive data

โœ… Security report saved to: security_report.json

๐Ÿ” How It Works

  1. Directory Scanning: Recursively scans your project directory
  2. Pattern Matching: Uses intelligent patterns to detect technologies
  3. Template Fetching: Retrieves templates from gitignore.io API
  4. Smart Merging: Combines templates and removes duplicates
  5. Content Generation: Creates optimized .gitignore content
  6. File Writing: Saves the result with optional backup

๐Ÿ› Troubleshooting

No Technologies Detected

If no technologies are detected, try:

# Use interactive mode to manually select templates
gitignore-gen --interactive

# Or specify a template directly
gitignore-gen templates --template python

API Connection Issues

The tool includes fallback templates for common technologies. If the API is unavailable, it will use bundled templates.

Permission Errors

Ensure you have read permissions for the directory you're scanning:

# Check permissions
ls -la

# Run with appropriate permissions
sudo gitignore-gen  # if needed

Template Fetch Errors

If templates fail to fetch, the tool will use built-in fallbacks:

# Check network connectivity
ping www.tgitignore.io

# Use offline mode (built-in templates)
gitignore-gen --offline

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

git clone https://github.com/Sherin-SEF-AI/gitignore-gen.git
cd gitignore-gen
pip install -e ".[dev]"
pre-commit install

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=gitignore_gen

# Run specific test file
pytest tests/test_detector.py

Code Quality

# Format code
black gitignore_gen tests

# Sort imports
isort gitignore_gen tests

# Lint code
flake8 gitignore_gen tests

# Type checking
mypy gitignore_gen

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

๐Ÿ”„ Changelog

See CHANGELOG.md for a detailed history of changes.


By Sherin Joseph Roy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gign-1.0.0.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gign-1.0.0-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file gign-1.0.0.tar.gz.

File metadata

  • Download URL: gign-1.0.0.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for gign-1.0.0.tar.gz
Algorithm Hash digest
SHA256 159224f69ab9ad9679970672200faa9218ab930baf0822dc3e364c591c7fdba1
MD5 8142e08c207d23c727f9003341c619bd
BLAKE2b-256 43effc92a2538cf7b41ccb3260b7e0036611a9b8be8d39be9963e15caeedc5d8

See more details on using hashes here.

File details

Details for the file gign-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: gign-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for gign-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3513eff35a058919744cc47e6c69ac62f2feb06a3f59f7f85abd6be26a3ae4a
MD5 3ef9a38fcaf593e3e11d5451426b3df8
BLAKE2b-256 df6c9c812fcf6fadb7f22c690bdd16aec839fb0b102202a4e7a63a3c89f22580

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page