Skip to content
Best Practices7 min readVerified Git 2.40+

.gitignore Examples for Modern Tech Stacks

Curated, practical .gitignore examples for popular languages, backend frameworks, game engines, mobile development, and containerized stacks.

1. Node.js, TypeScript & React / Next.js

Standard ignore template covering modern JavaScript package managers (npm, pnpm, yarn, bun), TypeScript compiler outputs, Next.js build caches, and local environment files:

gitignore
# 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
.env

2. Python, Virtual Environments & Bytecode

Essential Python exclusions filtering out compiled bytecode, virtual environments (venv, poetry, pipenv), distribution packages, and test caches:

gitignore
# 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/

3. Java, Maven & Gradle

Exclusions for JVM projects using Maven and Gradle build tools, compiled .class files, JAR artifacts, and local build daemon caches:

gitignore
# Compiled class files
*.class

# Package files
*.jar
*.war
*.ear

# Maven build directory
target/
pom.xml.tag
pom.xml.releaseBackup

# Gradle build cache
.gradle/
build/

4. .NET, C# & Visual Studio

Filters out Roslyn compiler outputs, NuGet package caches, user-specific Visual Studio solution caches, and publish directories:

gitignore
# Build results
[Bb]in/
[Oo]bj/

# Visual Studio user files
.vs/
*.user
*.suo
*.userosscache

# Publish outputs
publish/

5. Unity & Game Engines

Game development projects require excluding gigabytes of transient asset caches, native package imports, and temporary build outputs:

gitignore
# Large generated asset cache
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/

# Memory dumps
sysinfo.txt
*.stackdump

6. Docker, DevOps & Local Secrets

Rules to safeguard containerized environments and prevent committing local secrets or local compose overrides:

gitignore
# Local compose overrides
docker-compose.override.yml

# Environment secrets
.env
*.env.local

# Kubernetes local contexts
kubeconfig
*.kubeconfig

Frequently 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.

← Read GuidesOpen in Full Generator