Professional .gitignore file generator with 17+ built-in templates, smart merging, and automatic duplicate removal.
- 🚀 17+ Built-in Templates - Python, Node, Rust, C, C++, Java, Go, Swift, Ruby, PHP, TypeScript, VS Code, Vim, IntelliJ, macOS, Linux, Windows
- 🔄 Smart Merging - Automatically appends to existing
.gitignoreand removes duplicates - 📝 Multiple Patterns - Add multiple files/paths at once:
gitignore node_modules/ *.log .env - 🎯 Auto-detection - Scans your project and suggests appropriate templates
- 🎨 Interactive Mode - User-friendly template selection with
-tor-Iflags - 🌐 GitHub Sync - Download official templates from GitHub's repository
- 💾 Backup & Restore - Automatic backups with easy restoration
- 🔧 Template Generator - Easy-to-add custom templates (just drop
.gitignorefiles) - 🎯 Smart PREFIX - Install anywhere:
PREFIX=~/.local make install - ⚡ Fast - Templates compiled into binary, no external files needed
- 🎨 Colored Output - Beautiful terminal display
- 🪟 Cross-platform - Linux, macOS, and Windows support
curl -sSL https://raw.githubusercontent.com/mahbubhs/gitignore/main/install.sh | bash# Install to ~/.local (no sudo required)
curl -sSL https://raw.githubusercontent.com/mahbubhs/gitignore/main/install.sh | bash -s ~/.local
# Or use environment variable
export PREFIX=~/.local
curl -sSL https://raw.githubusercontent.com/mahbubhs/gitignore/main/install.sh | bashgit clone https://github.com/mahbubhs/gitignore.git
cd gitignore
make
sudo make install# Install to custom location
make PREFIX=~/.local install
# Or set environment variable
export PREFIX=/opt/gitignore
make install
# Check installation path
make show-prefix- GCC or Clang compiler
- libcurl (for GitHub sync)
- Make
Install dependencies:
# Ubuntu/Debian
sudo apt-get install build-essential libcurl4-openssl-dev
# macOS
brew install curl
# Fedora/RHEL
sudo dnf install gcc make libcurl-devel# Auto-detect project type
gitignore auto
# Create with specific templates
gitignore init python node
# Add multiple patterns at once
gitignore node_modules/ *.log .env dist/
# Interactive mode (quick)
gitignore -tSingle pattern:
gitignore node_modules/
gitignore *.log
gitignore .envMultiple patterns at once:
# Add several patterns in one command
gitignore node_modules/ *.log .env dist/
# Add temporary files
gitignore *.tmp *.swp *~ *.bak✨ Smart Features:
- ✅ Checks for duplicates before adding
- ✅ Appends to existing
.gitignore - ✅ Skips patterns that already exist
- ✅ Works even if
.gitignoredoesn't exist
Using built-in templates:
# Single language
gitignore init python
# Multiple languages
gitignore init python node rust
# Language + Editor + OS
gitignore init python vscode macos✨ Smart Features:
- ✅ Works even if
.gitignoreexists (appends, doesn't overwrite) - ✅ Removes duplicate patterns automatically
- ✅ Preserves existing patterns
- ✅ No external template files needed (compiled into binary)
gitignore autoAutomatically detects:
package.json→ Node.jsrequirements.txt/setup.py→ PythonCargo.toml→ Rustgo.mod→ Gopom.xml/build.gradle→ Java- And more...
# Three ways to start
gitignore interactive
gitignore -t # Quick shortcut
gitignore -I # Alternative shortcutShows a numbered menu of available templates for easy selection.
Download official templates directly from GitHub:
# Single language
gitignore sync python
# Multiple languages
gitignore sync rust c cpp goFeatures:
- ✅ Downloads from GitHub's official repository
- ✅ Merges with existing
.gitignore - ✅ Removes duplicates automatically
- ✅ Caches for 24 hours (faster repeated operations)
# Show all available templates
gitignore list
# Filter templates
gitignore list python
# Show built-in only
gitignore list --builtin
# Show custom only
gitignore list --local
# Preview template contents
gitignore show python
gitignore cat rustThe tool intelligently distinguishes between patterns and commands:
- Contains
/(slash):node_modules/,dist/ - Contains
*(asterisk):*.log,*.tmp - Contains
.(dot):.env,.DS_Store - File/directory exists:
myfile.txt
Command names: init, sync, list, show, cat, auto, interactive, append, update, global, backup, restore, backups, history, cache
# These run commands
gitignore init # Runs init command
gitignore sync # Runs sync command
# To add as patterns, use --add
gitignore --add init # Adds 'init' as pattern
gitignore --add sync list # Adds 'sync' and 'list' as patternsClear error messages:
$ gitignore sync
✗ Error: Ambiguous argument - did you mean a command or pattern?
If you want to use the 'sync' command, check: gitignore --help
If you want to add 'sync' as a pattern, use: gitignore --add sync- python - Python projects
- node - Node.js / JavaScript
- rust - Rust projects
- c - C projects
- cpp - C++ projects
- java - Java projects
- go - Go projects
- swift - Swift / iOS projects
- ruby - Ruby projects
- php - PHP projects
- typescript - TypeScript projects
- vscode - Visual Studio Code
- vim - Vim editor
- intellij - IntelliJ IDEA / JetBrains IDEs
- macos - macOS specific patterns
- linux - Linux specific patterns
- windows - Windows specific patterns
✨ All templates are compiled into the binary - no external files needed!
# Create global .gitignore
gitignore global init
# Add templates to global .gitignore
gitignore global add macos vscode
# Enable in git
git config --global core.excludesfile ~/.gitignore_global# Create backup
gitignore backup
# List available backups
gitignore backups
gitignore history
# Restore from backup
gitignore restore <backup_name># Append templates (simple append)
gitignore append python
# Smart update (removes duplicates)
gitignore update node vscodePreview what would happen without making changes:
gitignore --dry-run init python node
gitignore --dry-run auto
gitignore --dry-run sync rust# Clear template cache (GitHub synced templates)
gitignore cache clearCreate your own templates in ~/.config/gitignore/templates/:
# Create custom template
mkdir -p ~/.config/gitignore/templates
cat > ~/.config/gitignore/templates/myproject.gitignore << 'EOF'
# My custom project patterns
.myconfig
secrets/
*.secret
temp/
EOF
# Use it
gitignore init myprojectTemplate Priority: Custom templates override built-in templates with the same name.
Want to add a new built-in template? It's easy!
# 1. Create template file
cat > templates/django.gitignore << 'EOF'
# Django
*.log
*.pot
*.pyc
__pycache__/
db.sqlite3
media/
staticfiles/
EOF
# 2. Regenerate templates.c
make regen-templates
# 3. Build
make
# Done! Your template is now built-in
gitignore init djangoSee docs/ADDING_TEMPLATES.md for complete guide.
Configuration file: ~/.config/gitignore/config.conf
# gitignore configuration file
auto_backup=true # Auto-backup before changes
cache_enabled=true # Enable template caching
cache_duration=86400 # Cache duration (24 hours)
verbose=false # Verbose output
use_color=true # Colored terminal output
cd my-python-project
gitignore init python vscodecd existing-project
# .gitignore already exists with some patterns
gitignore init rust
# ✅ Rust patterns added
# ✅ Existing patterns preserved
# ✅ Duplicates removedgitignore node_modules/ .env *.log dist/
# ✅ All 4 patterns added at once
# ✅ Duplicates automatically skippedgitignore init python node rust go
# ✅ All 4 languages merged
# ✅ Duplicates removed
# ✅ Works even if .gitignore exists# Start a new project
mkdir my-app && cd my-app
git init
# Auto-detect and create .gitignore
gitignore auto
# Add custom patterns
gitignore secrets/ *.key
# Backup before major changes
gitignore backup
# Update with more templates
gitignore init docker nginx# Existing .gitignore:
node_modules/
.env
# Run: gitignore init python
# Result:
node_modules/ # ✅ Kept (from existing)
.env # ✅ Kept (from existing)
__pycache__/ # ✅ Added (from Python template)
*.py[cod] # ✅ Added (from Python template)
# No duplicates!1. Custom templates (~/.config/gitignore/templates/) ← Highest priority
2. Built-in templates (compiled in binary) ← Fallback
# Add pattern
gitignore node_modules/
# Try to add again
gitignore node_modules/
# Output: ⚠ All patterns already exist in .gitignoremake devmake test# 1. Create template file in templates/
echo "*.myext" > templates/mytemplate.gitignore
# 2. Regenerate
make regen-templates
# 3. Build
make
# 4. Test
./gitignore init mytemplatemake # Build project
make templates # Generate templates.c
make regen-templates # Force regenerate templates
make clean # Clean build artifacts
make distclean # Clean including generated files
make install # Install to PREFIX
make uninstall # Remove installation
make test # Run tests
make package # Create distribution tarball
make show-prefix # Show installation prefix
make help # Show all targets- ✅ Templates compiled into binary (no file I/O)
- ✅ Fast pattern matching and deduplication
- ✅ Efficient duplicate detection algorithm
- ✅ Template caching for GitHub sync (24h TTL)
Contributions are welcome! See CONTRIBUTING.md
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Add your template to
templates/directory - Run
make regen-templates - Test:
make && make test - Commit:
git commit -m 'feat: add amazing-feature template' - Push:
git push origin feature/amazing-feature - Open a Pull Request
MIT License - see LICENSE file for details
- GitHub's gitignore repository for inspiration
- All contributors who help improve this tool
- GitHub Repository: https://github.com/mahbubhs/gitignore
- Issue Tracker: https://github.com/mahbubhs/gitignore/issues
- Changelog: CHANGELOG.md
- Documentation: docs/
Made with ❤️ for developers who value clean repositories
Star ⭐ this repository if you find it helpful!