.gitignore Generator

Generate .gitignore files for various project types and platforms.

Languages & Frameworks
More Languages
Operating Systems & IDEs

Understanding .gitignore

The .gitignore file tells Git which files and directories to ignore in a project. This prevents sensitive information, build artifacts, and temporary files from being committed to your repository.

Why Use .gitignore?

Security
  • Keep credentials and API keys out of version control
  • Prevent .env files from being committed
  • Protect sensitive configuration files
Performance
  • Reduce repository size
  • Speed up Git operations
  • Avoid tracking large binary files
Cleanliness
  • Keep repository organized
  • Avoid tracking build artifacts
  • Ignore OS-specific files
Collaboration
  • Prevent merge conflicts on IDE files
  • Allow team members to use different editors
  • Keep everyone's local configs private

.gitignore Pattern Syntax

Pattern Description Example
file.txt Ignore specific file Ignores file.txt in any directory
*.log Wildcard: any characters Ignores all .log files
temp/ Ignore directory Ignores entire temp directory
/build Ignore in root only Ignores /build but not src/build
**/logs Match in any directory Ignores logs folder anywhere
docs/**/*.pdf Recursive pattern Ignores all PDFs in docs subdirs
!important.log Negate (don't ignore) Track this file even if *.log ignored
# comment Comment line Add explanatory comments

Common Files to Ignore

  • node_modules/ - Node.js packages
  • vendor/ - PHP/Ruby dependencies
  • __pycache__/ - Python bytecode
  • venv/ - Python virtual environment
  • packages/ - .NET packages

  • dist/, build/ - Build output
  • *.o, *.a - Compiled object files
  • *.class - Java compiled classes
  • *.pyc - Python compiled files
  • target/ - Maven/Gradle output

  • .env, .env.local - Environment variables
  • secrets.json - API keys and secrets
  • config/local.yml - Local configuration
  • *.pem, *.key - Private keys
  • credentials.json - Credentials

  • .DS_Store - macOS folder attributes
  • Thumbs.db - Windows thumbnail cache
  • desktop.ini - Windows folder config
  • *~ - Backup files

  • .vscode/ - VS Code settings
  • .idea/ - IntelliJ/WebStorm
  • *.swp, *.swo - Vim swap files
  • .project, .classpath - Eclipse

Best Practices

DO:
  • Create .gitignore before first commit
  • Use comments to organize sections
  • Be specific to avoid over-ignoring
  • Commit .gitignore to repository
  • Use templates for common project types
DON'T:
  • Ignore .gitignore itself
  • Commit and then add to .gitignore (remove first)
  • Use overly broad patterns
  • Forget to ignore IDE-specific files

Removing Already-Committed Files

If you already committed files that should be ignored:

# Remove from Git but keep locally
git rm --cached filename

# Remove entire directory
git rm -r --cached directory/

# Commit the removal
git commit -m "Remove ignored files from Git"
Never Commit!

Always ignore:

  • Passwords & API keys
  • Private keys (.pem, .key)
  • .env files
  • Database files
  • User uploaded content
  • Compiled binaries
  • Large files (>100MB)
Browse Tools

Tool Navigation

629+ tools across 43 categories