.gitignore Generator: how it works and how to build one
Build a .gitignore for Node, Next.js, Python, Java and more. This guide explains what happens behind the button and shows the code, so you can build your own.
What it does
Pick your languages, frameworks, editors and operating systems and get one combined .gitignore with sections and no duplicates. Covers Node, Next.js, React, Python, Django, Java, Android, Flutter, Go, PHP/Laravel, WordPress, VS Code, JetBrains, macOS and Windows.
When to use it
- Starting a new repository
- Stopping .env files from being committed
- Cleaning up a messy repo
How to use it
- Tick what your project uses.
- Check the combined file.
- Download it as .gitignore.
Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/gitignore-generator
How it works
.gitignore lists file patterns git should never track: dependencies, build output, secrets and editor files. The generator keeps a template per technology, joins the ones you pick with section headers, and drops any line that already appeared, so the file has no duplicates.
Patterns ending in / match folders; ! re-includes something an earlier line excluded.
Build it yourself
Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any TypeScript or JavaScript project.
gitignore.ts (ts)
const TEMPLATES: Record<string, string[]> = {
Node: ["node_modules/", "dist/", ".env", ".env.*", "!.env.example", "npm-debug.log*"],
"Next.js": [".next/", "out/", "next-env.d.ts"],
macOS: [".DS_Store"],
};
export function gitignore(picks: string[]) {
const seen = new Set<string>();
return picks.map((k) => {
const lines = TEMPLATES[k].filter((l) => !seen.has(l) && seen.add(l));
return lines.length ? `# ${k}\n${lines.join("\n")}` : "";
}).filter(Boolean).join("\n\n") + "\n";
}
Make it production-ready
- Pull templates from github/gitignore for more languages.
Questions
I already committed node_modules. What now?
Add it to .gitignore, then run git rm -r –cached node_modules and commit.
Free, runs in your browser, nothing is uploaded.