Index

.gitignore Templates

Quick-reference for common .gitignore patterns — macOS, Node, Python, and more.

What is a .gitignore?

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.

macOS

Always add these to avoid committing Finder metadata:

# macOS
.DS_Store
.AppleDouble
.LSOverride
Spotlight-V100
.Trashes

.DS_Store files are created silently by Finder on every folder you open. Without this rule they'll end up in every commit from a Mac.

Node.js

# 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

# Python
__pycache__/
*.py[cod]
*.egg-info/
dist/
build/
.venv/
.env

Global gitignore

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.

Last updated: 18-05-2026 at 13:17