My Default .gitignore File
Every time I create a new Git repo, I always have to go look for a previous copy of my .gitignore file. I thought it would be a great idea to just post it up for all to find. This template covers .NET, Node.js, and common development artifacts.
Update 2025: I’ve completely rewritten this for modern development workflows. The original 2012 version had patterns for Visual Studio 2010 - we’ve come a long way!
Quick Start
For most projects, I recommend using gitignore.io to generate a tailored .gitignore. But here’s my default starting point:
# Build outputs
[Bb]in/
[Oo]bj/
[Dd]ebug/
[Rr]elease/
x64/
x86/
build/
dist/
out/
# .NET specific
*.user
*.suo
*.userosscache
*.sln.docstates
*.userprefs
project.lock.json
.vs/
*.nupkg
*.snupkg
# Node.js
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-store/
# IDE and editors
.idea/
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.swp
*.swo
*~
# Environment and secrets
.env
.env.local
.env.*.local
*.local.json
appsettings.Development.json
secrets.json
# OS generated
.DS_Store
.DS_Store?
Thumbs.db
ehthumbs.db
Desktop.ini
# Testing
[Tt]est[Rr]esults/
coverage/
*.coverage
*.coveragexml
.nyc_output/
# Logs
logs/
*.log
# Package managers
packages/
.nuget/
# Temporary files
*.tmp
*.temp
*.bak
*.cache
Why These Patterns?
Build outputs (bin/, obj/, dist/): These are generated files that should never be committed. They bloat your repo and cause merge conflicts.
Environment files (.env): Never commit secrets! Use .env.example files to document required variables instead.
IDE folders (.vs/, .idea/): Personal IDE settings shouldn’t be shared. Exception: I do commit shared VSCode settings for team consistency.
Node modules: At 500MB+, this folder is the reason node_modules became a meme. Always ignore it.
Pro Tips
-
Use global gitignore for personal patterns:
git config --global core.excludesfile ~/.gitignore_global -
Check what’s being ignored:
git status --ignored -
Stop tracking a file that was already committed:
git rm --cached <file>
For more development tips, check out my PowerShell guide on recursively deleting files by extension or learn about building better connection strings in .NET.
About Kevin
Kevin Griffin has been running production .NET applications and teaching developers for over two decades. A 16-time Microsoft MVP specializing in ASP.NET Core and Azure, Kevin brings real-world experience from his own SaaS products alongside his consulting work at Swift Kick. He's hosted the Hampton Roads .NET User Group since 2009 and founded RevolutionVA, the nonprofit behind Hampton Roads DevFest. Kevin's talks blend hard-won lessons from production systems with practical advice you can use Monday morning.
Categories