Home / Configs / Developer tools / .gitignore file

.gitignore generator: ignore the right files for your project

Tick your languages and tools to get a .gitignore that keeps build files and secrets out of Git.

For any Git project. Pick the languages you use; the lines are common defaults, so edit them to match your project.

A .gitignore file tells Git which files to leave alone, such as node_modules, build folders and secret .env files. Tick what you use, copy the result into a file named .gitignore at the top of your project.

Create your config file

Type your own values. The file below updates as you type, and nothing you type leaves your browser.

.gitignore
# Node.js
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
dist/
build/
.next/
.nuxt/
coverage/
*.tsbuildinfo

# Secrets (keep a .env.example instead)
.env
.env.*
!.env.example

# Logs
*.log
logs/

# macOS
.DS_Store
._*

# Windows
Thumbs.db
ehthumbs.db
Desktop.ini

# VS Code
.vscode/

How this setup works

Diagram: .gitignore, then git add, then Clean repo
.gitignore (lists patterns) → git add (skips matches) → Clean repo (no junk or secrets)

Step-by-step setup

  1. Create a file named .gitignore (with the dot, no extension) in the top folder of your project.
  2. Paste the lines above into it and save.
  3. Check what Git sees: git status. Ignored files no longer appear.
  4. Commit it: git add .gitignore, then git commit -m "Add gitignore".
  5. If a file was already committed, stop tracking it: git rm -r --cached folder-name, then commit.

What the important lines mean

Common errors and how to fix them

A file is still tracked after I added it to .gitignore
.gitignore only affects files Git does not know yet. Run git rm --cached file-name (add -r for a folder), then commit.
My .gitignore does not work at all
Check the file is named exactly .gitignore, sits in the project folder, and has no hidden .txt on the end. Windows can add one.
git check-ignore -v file-name
This command shows which line of which .gitignore file matches. Use it to find out why a file is ignored or not.
I committed a secret by mistake
Adding it to .gitignore now does not remove it from history. Change the secret straight away, then remove the file from history with a tool such as git filter-repo.

Frequently asked questions

What does .gitignore do?
It tells Git not to track files that match its patterns, so build output, dependencies and secrets stay out of your repository.
Where do I put the .gitignore file?
In the top folder of your project. You can add more .gitignore files in subfolders for rules that apply only there.
Should I ignore package-lock.json or composer.lock?
No. Commit lock files for applications, so everyone installs the same versions.

Written for: Git 2 or newer · Updated 2026-10-11

More developer configs

See all 41 config generators