Git .gitignore

Control which files Git should ignore using .gitignore patterns and best practices.

On this page

What is .gitignore?

.gitignore tells Git which files and folders should not be tracked.

Common use cases

  • node_modules/
  • build/ and dist/ folders
  • .env files
  • log files

Basic example

node_modules/
*.log
.env
dist/

Ignoring specific file types

*.png
*.zip

Ignore everything except one file

*
!important.txt

Important note

.gitignore does not affect files already committed. You must remove them from tracking manually.