bashbeginner

.gitignore Patterns and Templates

Comprehensive .gitignore patterns for Node.js, Python, and general development environments.

bash
# .gitignore — Universal patterns

# === Dependencies ===
node_modules/
venv/
.env.local
.env*.local

# === Build outputs ===
dist/
build/
out/
.next/
__pycache__/
*.pyc

# === OS files ===
.DS_Store
Thumbs.db
*.swp
*.swo
*~

# === IDE files ===
.idea/
.vscode/
*.code-workspace
*.suo
*.ntvs*

# === Logs ===
logs/
*.log
npm-debug.log*
yarn-debug.log*

# === Secrets ===
.env
.env.production
*.pem
*.key

# === Testing ===
coverage/
.nyc_output/
.pytest_cache/

# === Misc ===
*.tgz
*.tar.gz
*.zip

# === Negate (force track) ===
!.gitkeep
!.env.example

# Check what's being ignored
# git status --ignored

# Remove cached file that's now in .gitignore
# git rm --cached filename

# Global gitignore
# git config --global core.excludesfile ~/.gitignore_global

Use Cases

  • Setting up gitignore for new projects
  • Preventing secrets from being committed
  • Cleaning up ignored tracked files

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.