ToolSphere

.gitignore Generator

More tools

Generate custom .gitignore files for Node, Python, Java, React, VS Code, macOS, and Windows. Includes recommended secret blocks to block credential leaks.

Languages
Frameworks
Editors
Operating systems
.gitignore
# Secrets and local environment
.env
.env.*
!.env.example
*.pem
*.key
secrets.json
credentials.json

# Node
node_modules/
npm-debug.log*
yarn-error.log*
.pnpm-debug.log*
.npm/
*.tsbuildinfo

# Next.js
.next/
out/
.vercel/
next-env.d.ts

# VS Code
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json

# macOS
.DS_Store
.AppleDouble
._*
.Spotlight-V100
.Trashes

.gitignore only prevents files from being added. A file Git is already tracking keeps being tracked however you ignore it — run git rm --cached <file> to stop it. And if a secret has already been pushed, removing it from history is not enough: treat it as compromised and rotate it.

On this browser only

Give feedback

Did this tool help?

Tell us what worked, what didn’t, or what you’d like next.

Opens Google Forms in a new tab with this tool’s name filled in. No sign-in or email required. Feedback is optional.

How to use .gitignore Generator

  1. 1Select the languages and frameworks your project uses.
  2. 2Add your editor and operating system so local cruft stays out of the repository.
  3. 3Keep the secrets block ticked unless you have a specific reason not to.
  4. 4Copy the result or download it straight as .gitignore.

About .gitignore Generator

The file that stops the commit you cannot take back

A .gitignore keeps generated and local files out of version control: dependency directories, build output, editor settings, operating-system cruft. Mostly it saves noise in diffs. Occasionally it saves a great deal more than that — the single most common way credentials leak into a public repository is a .env file committed on day one and forgotten.

That is why the secrets block here is on by default and lists .env, *.pem, *.key and the usual credential filenames, with !.env.example negated so the template file your teammates need stays tracked.

Pick your stack, not a maximal list

Generated .gitignore files are often enormous, covering twenty languages a project does not use. Length is not the point — coverage of the files you would otherwise forget is. Select the languages, frameworks, editors and operating systems actually in play and you get a file short enough that a reviewer will read it.

Where two selections define the same rule — build/ in Java and Android, for instance — the tool tells you rather than silently emitting it twice. Git does not care about the repetition, but a tidy file is easier to maintain.

What .gitignore cannot do

Ignoring a file only prevents it being added. A file Git already tracks stays tracked no matter what rules you write; you have to untrack it explicitly with git rm --cached <file>. This surprises people regularly: they add .env to .gitignore, see it still appearing in diffs, and assume the pattern is wrong.

And if a secret has already been pushed to a remote, rewriting history is not sufficient. Assume it has been cloned, scraped or cached. Rotate the credential — that is the only step that genuinely fixes it.

Frequently asked questions

I added a file to .gitignore and Git still tracks it. Why?

Ignoring only prevents a file being added. One Git already tracks stays tracked until you untrack it with git rm --cached <file>.

Is it enough to remove a leaked secret from history?

No. Assume anything pushed to a remote has been cloned or scraped. Rewriting history is worth doing, but rotating the credential is the step that actually fixes the problem.

Why is .env.example not ignored?

The generated secrets block negates it with !.env.example so the template your teammates need to set up the project stays committed while the real .env does not.

Should I ignore Cargo.lock or package-lock.json?

Commit lock files for applications so builds are reproducible. Libraries are the exception — for a Rust library, Cargo.lock is conventionally ignored, which is why that line is commented in the Rust template.

Why not just use one giant .gitignore for everything?

Because nobody reads it. A file covering only the stacks in play stays short enough to review, which is what makes it maintainable.

Have a suggestion for .gitignore Generator?Share your feedback ↗