.gitignore Examples for Modern Tech Stacks
Curated, practical .gitignore examples for popular languages, backend frameworks, game engines, mobile development, and containerized stacks.
Standard ignore template covering modern JavaScript package managers (npm, pnpm, yarn, bun), TypeScript compiler outputs, Next.js build caches, and local environment files:
# Dependencies
node_modules/
.pnp
.pnp.js
# Build outputs & caches
dist/
build/
.next/
out/
# Logs & runtime files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.turbo
# Environment variables
.env*.local
.envEssential Python exclusions filtering out compiled bytecode, virtual environments (venv, poetry, pipenv), distribution packages, and test caches:
# Bytecode & cache
__pycache__/
*.py[cod]
*$py.class
# Virtual environments
.venv/
venv/
env/
ENV/
# Distribution & packaging
build/
dist/
*.egg-info/
# Pytest & coverage
.pytest_cache/
.coverage
htmlcov/Exclusions for JVM projects using Maven and Gradle build tools, compiled .class files, JAR artifacts, and local build daemon caches:
# Compiled class files
*.class
# Package files
*.jar
*.war
*.ear
# Maven build directory
target/
pom.xml.tag
pom.xml.releaseBackup
# Gradle build cache
.gradle/
build/Filters out Roslyn compiler outputs, NuGet package caches, user-specific Visual Studio solution caches, and publish directories:
# Build results
[Bb]in/
[Oo]bj/
# Visual Studio user files
.vs/
*.user
*.suo
*.userosscache
# Publish outputs
publish/Game development projects require excluding gigabytes of transient asset caches, native package imports, and temporary build outputs:
# Large generated asset cache
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
# Memory dumps
sysinfo.txt
*.stackdumpRules to safeguard containerized environments and prevent committing local secrets or local compose overrides:
# Local compose overrides
docker-compose.override.yml
# Environment secrets
.env
*.env.local
# Kubernetes local contexts
kubeconfig
*.kubeconfigFrequently Asked Questions
Practical answers to common developer questions about .gitignore rules, caching, and repository configuration.
How do I combine rules for multi-language projects?
Combine templates deterministically by concatenating stack sections while removing duplicate lines. DotGitIgnore automates this without syntax conflicts.
Should package lockfiles (package-lock.json, poetry.lock) be ignored?
No. Lockfiles ensure identical dependency versions across team members and CI pipelines. They should always be committed to Git.
What is the best way to handle secrets like API keys?
Never commit secrets to Git. Add .env to .gitignore and commit a sanitized template like .env.example with dummy credentials.
.gitignore Guides & Reference
How to Ignore Already Tracked Files in Git
The definitive guide to resolving the common Git issue: untracking sensitive or generated files that were accidentally committed before adding a .gitignore.
.gitignore Syntax & Pattern Matching Guide
Comprehensive breakdown of pattern format, wildcard globbing, leading/trailing slashes, negation nuances, and character ranges in Git ignore files.
How to Ignore a Directory in Git
Clear explanation of directory ignore rules: trailing slash behavior, root-relative folders, subdirectories, and keeping empty directories.