This comprehensive guide covers all available templates in gitignore, including built-in templates, custom templates, and GitHub synchronization.
Gitignore uses a multi-tier template system for maximum flexibility:
βββββββββββββββββββββββββββββββββββββββ
β Custom Templates β Highest Priority
β ~/.config/gitignore/templates/ β
βββββββββββββββββββββββββββββββββββββββ€
β Built-in Templates β Compiled in binary
β templates/*.gitignore β
βββββββββββββββββββββββββββββββββββββββ€
β GitHub Sync Templates β Downloaded on-demand
β github.com/github/gitignore β
βββββββββββββββββββββββββββββββββββββββ
| Category | Count | Description | Examples |
|---|---|---|---|
| Languages | 8 | Programming language specific | Python, Node.js, Rust |
| Editors | 3 | IDE and editor configurations | VS Code, IntelliJ, Vim |
| Operating Systems | 3 | OS-specific files | macOS, Linux, Windows |
| Infrastructure | 4 | DevOps and container tools | Docker, Kubernetes |
| Total Built-in | 18 | All categories combined | - |
Template: python
Use Case: Python applications, libraries, and data science projects
Pattern Count: 148 lines
Ignored Categories:
*.pyc, *.pyo, __pycache__/build/, dist/, *.egg-info/venv/, env/, .venv/.coverage, htmlcov/, .tox/docs/_build/.vscode/, .idea/, *.swp.DS_Store, Thumbs.dbUsage Examples:
# Basic Python project
gitignore init python
# Django application
gitignore init python django vscode
# Data science project
gitignore init python jupyter vscode linux
Template: node
Use Case: Node.js applications, npm packages, and JavaScript projects
Pattern Count: 156 lines
Ignored Categories:
node_modules/, npm-debug.log*logs/, *.log, pids/lib-cov/, *.pid, *.seedcoverage/, .nyc_output/dist/, build/, .next/.env, .env.local.vscode/, .idea/Framework-Specific Patterns:
.next/, out/dist/, tmp/dist/, .cache/Template: rust
Use Case: Rust applications, libraries, and Cargo projects
Pattern Count: 89 lines
Ignored Categories:
target/, debug/, release/Cargo.lock (optional), .cargo/*.bk, *.orig.vscode/, .idea/, *.swp.DS_Store, Thumbs.dbCargo-Specific:
~/.cargo/registry/~/.cargo/git/target/Templates: c, cpp
Use Case: System programming, embedded development, and compiled applications
Pattern Count: 67 lines
*.o, *.ko, *.obj*.exe, *.out, *.app*.a, *.so, *.dylibbuild/, bin/, cmake-build/Pattern Count: 94 lines
*.o, *.obj, *.lib*.exe, *.outcmake-build/, build/*.sln, *.vcxproj, .vs/Template: java
Use Case: Java applications, Maven/Gradle projects, and JVM development
Pattern Count: 112 lines
Ignored Categories:
*.class, *.jar, *.wartarget/, out/, build/.idea/, *.iml, .classpath.mvn/, pom.xml.tag.gradle/, gradle-app.setting.project, .settings/Template: go
Use Case: Go applications, modules, and microservices
Pattern Count: 78 lines
Ignored Categories:
*.exe, *.exe~, *.dll*.tmp, *.test*.out, coverage.txtvendor/, Gopkg.lock.vscode/, .idea/Go-Specific:
go.sum (optional)Template: vscode
Pattern Count: 23 lines
Ignored:
.vscode/ (settings, extensions, launch configs)Template: intellij
Pattern Count: 45 lines
Ignored:
.idea/ (project files, workspace settings)out/ (compilation output)*.iml (module files)Template: vim
Pattern Count: 18 lines
Ignored:
*.swp, *.swo (swap files)*.bak, *~ (backup files)*.un~ (undo files).netrwhist (netrw history)Template: git
Pattern Count: 12 lines
Ignored:
.git/ (Git repository data).gitignore (self-referential)Template: macos
Pattern Count: 156 lines
Ignored Categories:
.DS_Store, .AppleDouble/.Spotlight-V100/, .TemporaryItems/.Trashes/._*, .DocumentRevisions-V100/Template: linux
Pattern Count: 34 lines
Ignored:
*~ (backup files)core (core dumps)/tmp/ contentsTemplate: windows
Pattern Count: 67 lines
Ignored:
Thumbs.db, ehthumbs.dbDesktop.ini$RECYCLE.BIN/*.stackdumpTemplate: docker
Pattern Count: 45 lines
Ignored:
Template: kubernetes
Pattern Count: 23 lines
Ignored:
kubectl configuration dumpsTemplate: terraform
Pattern Count: 34 lines
Ignored:
.terraform/*.tfstate*Template: ansible
Pattern Count: 28 lines
Ignored:
*.retry filesCreate personalized templates in your user configuration directory:
# Create templates directory
mkdir -p ~/.config/gitignore/templates
# Create a custom Django template
cat > ~/.config/gitignore/templates/django.gitignore << 'EOF'
# Django Project Template
# Database
*.sqlite3
*.db
# Static files
staticfiles/
static/
# Media files
media/
# Environment variables
.env
.env.local
# Python bytecode
__pycache__/
*.pyc
# IDE
.vscode/
.idea/
EOF
Custom templates are automatically discovered and have the highest priority:
# List all templates (custom + built-in)
gitignore list
# Use custom template
gitignore init myproject
# Custom templates override built-in ones
gitignore init python # Uses your custom python template if it exists
Structure your templates professionally:
# ===========================================
# Custom Template for [Project Type]
# ===========================================
# Description: Brief explanation of what this template ignores
# Author: Your Name
# Version: 1.0.0
# Last Updated: YYYY-MM-DD
# 1. Build Artifacts
# ------------------
dist/
build/
target/
# 2. Dependencies
# ---------------
node_modules/
vendor/
# 3. Environment & Secrets
# ------------------------
.env*
secrets/
# 4. IDE & Editor Files
# ---------------------
.vscode/
.idea/
*.swp
# 5. OS Generated Files
# ---------------------
.DS_Store
Thumbs.db
# 6. Logs & Temporary Files
# -------------------------
*.log
*.tmp
.cache/
Ensure your templates follow best practices:
# Show all available templates
gitignore list
# Filter by keyword
gitignore list python
# Show detailed information
gitignore list --verbose
# Show only built-in templates
gitignore list --builtin
# Show only custom templates
gitignore list --local
# Display template contents
gitignore show python
# Show multiple templates
gitignore show python node
# Preview custom template
gitignore show mytemplate
Each template includes metadata:
$ gitignore show python --info
Template: python
Source: Built-in
Lines: 148
Categories: Python, IDE, OS
Last Updated: 2024-01-15
Description: Comprehensive Python .gitignore
Download templates directly from GitHubβs official repository:
# Sync single template
gitignore sync python
# Sync multiple templates
gitignore sync rust go java
# Force refresh (ignore cache)
gitignore sync python --no-cache
github.com/github/gitignore.gitignoreAll official GitHub templates are available for sync, including:
| Language | Framework | Tool |
|---|---|---|
| Python, JavaScript, Java | Django, React, Spring | Docker, Kubernetes |
| Go, Rust, C/C++ | Rails, Laravel | Terraform, Ansible |
| PHP, Ruby, Swift | Vue, Angular | AWS, Azure |
| Category | Templates | Avg Patterns | Total Patterns | Coverage |
|---|---|---|---|---|
| Languages | 8 | 98 | 784 | 43.6% |
| Editors | 3 | 29 | 87 | 4.8% |
| Operating Systems | 3 | 86 | 258 | 14.3% |
| Infrastructure | 4 | 33 | 132 | 7.3% |
| Total Built-in | 18 | 69 | 1,261 | 100% |
Most Popular Templates:
python - 148 patterns (Data science, web dev)node - 156 patterns (Full-stack JavaScript)vscode - 23 patterns (Universal editor)linux - 34 patterns (Cross-platform dev)macos - 156 patterns (macOS development)Create Template:
# Add to templates/ directory
vim templates/swift.gitignore
Regenerate Database:
make regen-templates
Test Template:
make && ./gitignore init swift
Validate:
./gitignore show swift
./gitignore --dry-run init swift
# Check available templates
gitignore list
# Check spelling and variations
gitignore list | grep -i template
# For custom templates
ls ~/.config/gitignore/templates/
# Preview template contents
gitignore show python
# Dry run to see changes
gitignore --dry-run init python
# Check file permissions
ls -la .gitignore
# Verify template location
ls -la ~/.config/gitignore/templates/
# Check template syntax
cat ~/.config/gitignore/templates/mytemplate.gitignore
# Test template loading
gitignore list --local
# Check network connectivity
curl -I https://github.com
# Clear cache and retry
gitignore cache clear
gitignore sync python
# Use built-in templates as fallback
gitignore init python