📄 .gitignore Reference
A .gitignore file tells Git which files and folders to never track. Put it in the root of your repository. Copy the section that matches your stack — or combine multiple sections for mixed projects.
💡
Already committed a file by mistake? Adding it to
.gitignore won't remove it from tracking. Run git rm --cached <file> to untrack it without deleting it from disk, then commit.Quick Starter — Most Projects
A minimal baseline that works for almost any project. Start here, then add stack-specific rules below.
.gitignore
# ── Build output ──────────────────────────────────
bin/
obj/
dist/
out/
build/
target/
# ── Dependencies ──────────────────────────────────
node_modules/
.pnp/
.pnp.js
vendor/
# ── Environment & secrets ─────────────────────────
.env
.env.*
!.env.example
*.local
secrets.*
appsettings.local.*
# ── OS files ──────────────────────────────────────
.DS_Store
Thumbs.db
desktop.ini
# ── Editor / IDE ──────────────────────────────────
.vscode/
.idea/
*.suo
*.user
.NET / Visual Studio
Covers C#, VB.NET, F# projects created with Visual Studio or dotnet new. Includes ASP.NET Core and desktop apps.
.gitignore
# ── Build output ──────────────────────────────────
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# ── Visual Studio files ───────────────────────────
.vs/
*.suo
*.user
*.userosscache
*.sln.docstates
*.rsuser
.vscode/
# ── NuGet ─────────────────────────────────────────
*.nupkg
*.snupkg
.nuget/
packages/
!packages/repositories.config
project.lock.json
project.fragment.lock.json
artifacts/
# ── MSBuild / Roslyn ──────────────────────────────
*.pidb
*.svclog
*.scc
_Codegeneration*
# ── ASP.NET Core ──────────────────────────────────
wwwroot/lib/
appsettings.local.json
appsettings.*.local.json
# ── Test results ──────────────────────────────────
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
TestResult.xml
*.trx
*.coverage
*.coveragexml
OpenCover/
# ── Publish profiles ──────────────────────────────
*.[Pp]ublish.xml
*.azurePubxml
*.pubxml
!*[Pp]ublish[Pp]rofile.pubxml.user
PublishScripts/
# ── Docker (local only) ───────────────────────────
.dockerignore.local
# ── Environment / secrets ─────────────────────────
.env
.env.*
!.env.example
*.pfx
*.p12
Node.js / Angular / React / Vue
Works for any JavaScript or TypeScript project using npm, yarn, or pnpm. Includes Angular CLI, Create React App, and Vite setups.
.gitignore
# ── Dependencies ──────────────────────────────────
node_modules/
.pnp/
.pnp.js
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
# ── Build output ──────────────────────────────────
dist/
dist-ssr/
build/
out/
.next/
.nuxt/
.output/
.svelte-kit/
# ── Angular specific ──────────────────────────────
.angular/
.angular/cache/
# ── Environment files ─────────────────────────────
.env
.env.*
!.env.example
!.env.test
src/environments/environment.local.ts
# ── Testing & coverage ────────────────────────────
coverage/
.nyc_output/
*.lcov
/cypress/videos/
/cypress/screenshots/
# ── Logs ──────────────────────────────────────────
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# ── Cache & misc ──────────────────────────────────
.cache/
.parcel-cache/
.eslintcache
.stylelintcache
*.tsbuildinfo
Secrets & Environment Files
The most important section. These patterns protect credentials, API keys, and local config from ever being committed.
.gitignore
# ── Environment files ─────────────────────────────
.env
.env.local
.env.*.local
.env.development
.env.production
.env.staging
!.env.example # DO commit this — it's the template with no real values
# ── App-specific secrets ──────────────────────────
appsettings.local.json
appsettings.Production.json
secrets.json
config/secrets.yml
🚨
Always commit an
.env.example file with all the keys listed but no real values. This documents what secrets the project needs without exposing them.Tips & Syntax
| Pattern | What it ignores |
|---|---|
bin/ | The bin folder anywhere in the repo |
/bin/ | Only the bin folder at the repo root |
*.log | Any file ending in .log |
debug*.log | Files matching debug + anything + .log |
!important.log | Exception — do NOT ignore this specific file |
**/temp | A folder named temp at any depth |
doc/*.txt | .txt files directly inside doc/ (not subdirs) |
doc/**/*.txt | .txt files inside doc/ at any depth |
Useful commands
# Check if a file is being ignored (and why)
git check-ignore -v path/to/file
# List all currently ignored files
git status --ignored
# Stop tracking a file that's already committed (keep it on disk)
git rm --cached path/to/file
git commit -m "chore: untrack file"
# Stop tracking an entire folder
git rm -r --cached path/to/folder/
git commit -m "chore: untrack folder"