.gitignore
In one line
A .gitignore file lists patterns for files and directories that Git should intentionally not track.
In simple words
A .gitignore file tells Git which files and directories to skip. Each line is a glob pattern. Files matching a pattern are not shown in git status and cannot be accidentally committed.
Common things to ignore: build output (dist/, build/), dependencies (node_modules/), secrets (.env, *.key), OS files (.DS_Store, Thumbs.db), and editor configs (.vscode/, .idea/).
Patterns: * matches any characters, ** matches any directories, a trailing / means directory only, a leading / means root only, and ! negates a pattern (un-ignore). The .gitignore file itself should be committed so all team members share the same ignore rules.
Example
# .gitignore example
node_modules/
*.env
build/
dist/
.DS_Store
*.log
# Negate: track this .env file even though *.env is ignored
!.env.examplePatterns tell Git which files to skip. ! negates a pattern.
Related terms
Related Resources
Related Lessons
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.