How do I use the .gitignore generator?
- Tick the stacks your project uses.
- Press Build .gitignore.
- Save the result as .gitignore in your project root and commit it.
.gitignore generator: frequently asked questions
I already committed my .env file. Is adding it to .gitignore enough?
No. Remove it with git rm --cached .env, and rotate every secret in it, because it stays in Git history.
Should I commit package-lock.json?
Yes. Lock files make installs repeatable, so they belong in the repository.
What is a .gitignore file?
A list of files and folders Git should not track, such as dependencies, build output, logs and secrets.
Where do I put .gitignore?
In the root of your repository. Subfolders can have their own for local rules.
Why is a file still tracked after adding it to .gitignore?
Git keeps tracking files already committed. Remove it from the index with git rm --cached, then commit.
Should .env files be ignored?
Yes. Commit a .env.example with placeholder values instead, and keep real secrets out of Git.
Should I commit lock files?
Yes for applications (package-lock.json, pnpm-lock.yaml), so every install uses the same versions.
Can I ignore a folder but keep one file in it?
Yes: ignore folder/* and add !folder/keep.txt.
What should a Node.js project ignore?
node_modules, build folders such as .next or dist, logs, coverage output and environment files.
I committed a secret. Is .gitignore enough?
No. Rotate the secret immediately; it remains in Git history even after the file is removed.