Quick-reference for common .gitignore patterns — macOS, Node, Python, and more.
A .gitignore file tells Git which files and directories to ignore in a project. Anything listed will not be tracked, staged, or committed — keeping your repository clean of build artefacts, secrets, and editor noise.
Always add these to avoid committing Finder metadata:
# macOS
.DS_Store
.AppleDouble
.LSOverride
Spotlight-V100
.Trashes
.DS_Storefiles are created silently by Finder on every folder you open. Without this rule they'll end up in every commit from a Mac.
# Node
node_modules/
dist/
.env
.env.local
npm-debug.log*
yarn-error.log
.pnpm-debug.log
The key rule here is node_modules/ — this directory can contain hundreds of thousands of files and should never be committed.
# Python
__pycache__/
*.py[cod]
*.egg-info/
dist/
build/
.venv/
.env
You can configure a global .gitignore that applies to every repo on your machine:
git config --global core.excludesFile ~/.gitignore_global
Then put your editor and OS patterns in ~/.gitignore_global so you don't have to repeat them in every project.
.gitignore focused on project-specific rulesLast updated: 18-05-2026 at 13:17