gitignore

Template Reference

This comprehensive guide covers all available templates in gitignore, including built-in templates, custom templates, and GitHub synchronization.

πŸ“‹ Table of Contents

🎯 Template Overview

Template Architecture

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       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Template Categories

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 Features

πŸ–₯️ Programming Languages

Python

Template: python
Use Case: Python applications, libraries, and data science projects
Pattern Count: 148 lines

Ignored Categories:

Usage Examples:

# Basic Python project
gitignore init python

# Django application
gitignore init python django vscode

# Data science project
gitignore init python jupyter vscode linux

Node.js

Template: node
Use Case: Node.js applications, npm packages, and JavaScript projects
Pattern Count: 156 lines

Ignored Categories:

Framework-Specific Patterns:

Rust

Template: rust
Use Case: Rust applications, libraries, and Cargo projects
Pattern Count: 89 lines

Ignored Categories:

Cargo-Specific:

C/C++

Templates: c, cpp
Use Case: System programming, embedded development, and compiled applications

C Template

Pattern Count: 67 lines

C++ Template

Pattern Count: 94 lines

Java

Template: java
Use Case: Java applications, Maven/Gradle projects, and JVM development
Pattern Count: 112 lines

Ignored Categories:

Go

Template: go
Use Case: Go applications, modules, and microservices
Pattern Count: 78 lines

Ignored Categories:

Go-Specific:

πŸ› οΈ Development Tools

Editors & IDEs

Visual Studio Code

Template: vscode
Pattern Count: 23 lines

Ignored:

IntelliJ IDEA

Template: intellij
Pattern Count: 45 lines

Ignored:

Vim

Template: vim
Pattern Count: 18 lines

Ignored:

Version Control

Git

Template: git
Pattern Count: 12 lines

Ignored:

πŸ–₯️ Operating Systems

macOS

Template: macos
Pattern Count: 156 lines

Ignored Categories:

Linux

Template: linux
Pattern Count: 34 lines

Ignored:

Windows

Template: windows
Pattern Count: 67 lines

Ignored:

πŸ—οΈ Infrastructure & DevOps

Docker

Template: docker
Pattern Count: 45 lines

Ignored:

Kubernetes

Template: kubernetes
Pattern Count: 23 lines

Ignored:

Terraform

Template: terraform
Pattern Count: 34 lines

Ignored:

Ansible

Template: ansible
Pattern Count: 28 lines

Ignored:

🎨 Custom Templates

Creating Custom Templates

Create 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

Template Discovery

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

Template Format Standards

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/

Template Validation

Ensure your templates follow best practices:

πŸ”§ Template Management

Listing Templates

# 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

Previewing Templates

# Display template contents
gitignore show python

# Show multiple templates
gitignore show python node

# Preview custom template
gitignore show mytemplate

Template Information

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

🌐 GitHub Synchronization

Syncing Official Templates

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

Sync Features

Available Sync Templates

All 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

πŸ“Š Statistics & Analytics

Template Metrics

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%

Usage Statistics

Most Popular Templates:

  1. python - 148 patterns (Data science, web dev)
  2. node - 156 patterns (Full-stack JavaScript)
  3. vscode - 23 patterns (Universal editor)
  4. linux - 34 patterns (Cross-platform dev)
  5. macos - 156 patterns (macOS development)

Performance Characteristics

πŸ› οΈ Template Development

Contributing New Templates

  1. Create Template:

    # Add to templates/ directory
    vim templates/swift.gitignore
    
  2. Regenerate Database:

    make regen-templates
    
  3. Test Template:

    make && ./gitignore init swift
    
  4. Validate:

    ./gitignore show swift
    ./gitignore --dry-run init swift
    

Template Guidelines

πŸ†˜ Troubleshooting

Template Not Found

# Check available templates
gitignore list

# Check spelling and variations
gitignore list | grep -i template

# For custom templates
ls ~/.config/gitignore/templates/

Template Not Applying

# Preview template contents
gitignore show python

# Dry run to see changes
gitignore --dry-run init python

# Check file permissions
ls -la .gitignore

Custom Template Issues

# Verify template location
ls -la ~/.config/gitignore/templates/

# Check template syntax
cat ~/.config/gitignore/templates/mytemplate.gitignore

# Test template loading
gitignore list --local

Sync Problems

# 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