gitignore in Git

From the Git cheat sheet · Getting Started · verified Nov 2026

.gitignore

Tell Git which files and directories to ignore

bash
# Create .gitignore in repo root
# Common patterns:
node_modules/
.env
.env.local
dist/
build/
*.log
.DS_Store
.vscode/
.idea/

# Stop tracking a file that's already committed
git rm --cached <file>
git rm -r --cached <directory>
💡 .gitignore only affects untracked files
⚠️ Already-tracked files keep being tracked — use git rm --cached to stop
✅ Use a global ignore for OS/editor junk (.DS_Store, .vscode/)
📌 Commit .gitignore so the whole team shares it

Continue with Git

Save the full cheat sheet or work through every related task.

More Git tasks

Back to the full Git cheat sheet