Build a .gitignore from the stacks you actually run, with the lines that matter and none of the historical noise.
# Node node_modules/ npm-debug.log* yarn-error.log* .pnpm-debug.log* *.tsbuildinfo # Next.js .next/ out/ build/ .vercel/ next-env.d.ts # Environment .env .env.* !.env.example *.pem *.key # macOS .DS_Store .AppleDouble .LSOverride Icon ._* # Editors .vscode/* !.vscode/extensions.json .idea/ *.swp *.swo .claude/
Because those carry decades of tooling nobody uses any more, and a file nobody reads is a file where a real mistake hides. These are the lines that earn their place today.
A gitignore only affects untracked files. For something already in the history, run git rm --cached on it first, and rotate it if it was a secret: it stays in the history either way.
No, commit it: the point of a lock file is that everyone installs the same tree. The one exception is a Rust library, where Cargo.lock is conventionally left out.
Yes. A .gitignore applies to its own folder and everything under it, and patterns without a slash match at any depth. A pattern that starts with a slash is anchored to the file's own folder, which is how you ignore /build without ignoring src/build.