gitignore in Git

From the Git cheat sheet ยท Getting Started ยท verified Jul 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