What kinds of files should you put in .gitignore?
Generated, secret or machine-specific files: dependencies like node_modules, build output, logs, .env files, and editor or OS clutter. Source code and configuration the team needs must stay tracked.
Explain it simply
Ask of each file: can anyone rebuild it, or is it private to me? If so, it does not belong in the repository.
Dependencies come back through npm install. Build folders like dist/ come back from the build. Logs, caches and coverage reports are noise. .env files carry passwords and API keys, which must never be committed. Editor files like .vscode/ depend on taste. Commit a .env.example with fake values so teammates know what to set. Lock files such as package-lock.json should be committed.
Example
node_modules/
dist/
coverage/
*.log
.env
!.env.exampleWhat to say in the interview
"I ignore anything generated, secret or personal: dependencies, build output, logs, .env files and editor files. I keep lock files and an .env.example committed. Anything the project needs to run from source stays tracked."
Common mistakes
- Ignoring package-lock.json.