Installed dependencies
- Input
- node_modules/react/index.js
- Expected output
- ignorado / ignored
The node_modules/ folder is excluded and Git does not descend into it.
gitignore for node react next.js
The tool's Next.js shortcut combines the Next.js and Node templates with Visual Studio Code, macOS and Windows. Swap the selected items, copy the file and use the Test tab to check your project paths.
The node_modules/ folder is excluded and Git does not descend into it.
Matches the .env rule.
The !.env.example negation re-includes the file after .env.*.
.vscode/* ignores the contents, and !.vscode/settings.json re-includes this file.
The dist rule matches the folder and everything inside it.
It should be committed.
Tap the shortcut for your stack (Next.js, Python, Laravel, Unity and others) or search by name: react and vite open the Node template, django opens Python. Add the editor (Visual Studio Code, JetBrains) and the operating system (macOS, Windows, Linux) of the people working on the project, copy the result and save it as .gitignore at the repository root. Editor and OS templates can also go to a global file (core.excludesFile) so they do not clutter the project.
It is not mandatory, but it is the safest. The Next.js template covers .next, .vercel and next-env.d.ts, and the Node one covers caches, logs and tools such as Vite, Turbo and pnpm. Together, the repeats disappear.
No. Neither template ignores lock files, and the general advice is to commit them so installs are reproducible.
Because .env.* and .env*.local ignore it. Only .env.example is re-included, which is why it must hold no secret values.
Loading templates...
Pick at least one template to generate the file.
Loading templates...
# Normalize line endings: Git detects text files, LF in the repository. * text=auto eol=lf # Shell scripts need LF; Windows scripts need CRLF. *.sh text eol=lf *.bat text eol=crlf *.cmd text eol=crlf *.ps1 text eol=crlf # Binary files: no conversion and no text diff. *.png binary *.jpg binary *.jpeg binary *.gif binary *.ico binary *.webp binary *.pdf binary *.zip binary *.gz binary *.woff binary *.woff2 binary # Lock files: GitHub collapses them in diffs. package-lock.json linguist-generated yarn.lock linguist-generated pnpm-lock.yaml linguist-generated
.gitignore only applies to files Git does not track yet. To stop tracking without deleting from disk:
git rm --cached path/to/file git rm -r --cached path/to/folder git commit -m "Stop tracking ignored files"
To re-apply the .gitignore to everything at once (review git status before committing):
git rm -r --cached . git add . git commit -m "Apply .gitignore"
To ignore only on your machine, use a global file (core.excludesFile) or the clone's .git/info/exclude, with the same syntax:
git config --global core.excludesFile ~/.gitignore_global .git/info/exclude
No problems found in the rules.