Gitignore Generator

Gitignore Generator

Generate .gitignore files for any project. Templates for Node, Python, Java, Go, React, Vue, and more. Free online gitignore generator

A wrong .gitignore is one of the few mistakes in software development that follows you forever — once you commit node_modules or a .env, the file is in the history and the only way out is a force-push rebase. This generator builds a .gitignore from your stack (Node, Python, Java, Go, Rust, .NET, etc.) and tool set (IDE, OS, build artifacts), aligned with the patterns from github/gitignore that every CI system already understands.

How .gitignore patterns actually work

  • Patterns are tested against paths relative to the .gitignore file. A pattern in /backend/.gitignore only affects files under /backend.
  • A pattern without a / matches files anywhere in the tree below the .gitignore (e.g. *.log matches /a/b/c.log).
  • A pattern starting with / is anchored to the .gitignore directory: /build only matches /build, not /src/build.
  • A pattern ending with / matches directories only. logs/ ignores the directory logs but not a file named logs.
  • Prefix with ! to un-ignore: lines like *.log followed by !important.log keep important.log tracked. Order matters; later rules override earlier ones.
  • Wildcards: * (any non-slash chars), ** (any path depth), ? (one char), [abc] (character class). **/node_modules ignores node_modules at any depth.

Working example

Input

Stack: Node.js + TypeScript + VS Code on macOS

Output

# Node
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
.npm
.yarn/cache
.yarn/build-state.yml
.pnp.*

# TypeScript
*.tsbuildinfo
dist/
build/
out/

# Environment
.env
.env.local
.env.*.local

# IDE / Editor
.vscode/*
!.vscode/settings.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/tasks.json
.idea/
*.swp
*.swo

# OS
.DS_Store
.AppleDouble
.LSOverride
Thumbs.db
ehthumbs.db

# Logs and coverage
logs/
*.log
coverage/
.nyc_output/

Note the .vscode pattern: ignore .vscode/* but un-ignore the four files teams typically want to share. The order matters — !.vscode/settings.json must come after .vscode/*. The block for env files covers the common .env.development.local etc. patterns Next.js uses.

The patterns most projects miss

  • .env without .env.example — you ignore the secret file but commit a template showing variable names. Without the template, the next developer cannot run the project.
  • Build outputs that are committed as a temporary fix — dist/ committed "just to deploy" then never removed. Six months later the repo has 200MB of stale builds in history.
  • IDE configs — half the team uses VS Code, half uses JetBrains. Ignore .idea/ and .vscode/ globally, then un-ignore specific shared files explicitly.
  • OS metadata — .DS_Store, Thumbs.db, desktop.ini. These never belong in a repo and every cross-platform team accumulates them.
  • Test coverage and cache directories — coverage/, .pytest_cache/, .ruff_cache/, .mypy_cache/, .next/, .nuxt/. Regenerable; committing them creates merge conflicts.
  • Secrets that look like code — *.pem, *.key, .npmrc with auth tokens, ~/.gradle/gradle.properties with signing keys.

When to reach for this tool

  • You are starting a new repo and want a .gitignore that covers your stack without missing the common gotchas.
  • You added a new tool (Docker, Terraform, Jupyter) to an existing project and need the .gitignore patterns it produces.
  • You inherited a repo where node_modules is tracked and want to fix the .gitignore plus remove the directory from history.
  • You are setting up a polyglot monorepo and want stacked patterns for each language in one file.

What this tool will not do

  • It will not remove already-tracked files from the index. Adding node_modules to .gitignore does not stop git from tracking files already committed. Run git rm -r --cached node_modules to untrack, then commit.
  • It will not rewrite history. If a secret was committed, .gitignore prevents future commits but does not remove the secret from past commits. Use git filter-repo or BFG, then rotate the secret.
  • It will not detect what stacks you actually use. The output is only as accurate as the templates you select; a project that uses a tool you forgot to tick will still leak its artifacts.

Templates are generated locally from a static template set in the browser. No code or project metadata is sent anywhere.

Frequently asked questions

I committed a secret. Adding it to .gitignore did not help. Why?

.gitignore only prevents untracked files from being added. A file that is already tracked is still tracked. To fix: (1) git rm --cached <file> and commit; (2) for already-pushed secrets, use git filter-repo to scrub history; (3) rotate the secret regardless — assume it was scraped the moment it hit GitHub.

Where should the .gitignore file live?

At the repository root for project-wide rules. You can also have per-directory .gitignore files for rules that only apply to a subtree. For global user-level rules (editor backups, OS files), set core.excludesFile to ~/.gitignore_global.

How is .gitignore different from .gitattributes?

.gitignore controls which files git tracks. .gitattributes controls how git handles tracked files: line endings (text=auto), diff drivers (binary diffs for images), filter chains (LFS, smudge/clean), merge strategies per file type.

Can I have a global .gitignore that applies to all my repos?

Yes. git config --global core.excludesFile ~/.gitignore_global. Put your personal editor and OS noise there (.DS_Store, .idea/, *.swp). Keep project-specific patterns in the project repo so teammates inherit them.

Why is .gitignore not ignoring a file?

Almost always: the file is already tracked. Check with git check-ignore -v <path> — it tells you which rule (or none) matched, and where the rule came from. If the file is tracked, git rm --cached it.

What about .gitignore vs .gitignore_global vs .git/info/exclude?

Three levels: repo-level .gitignore (committed, shared with team), user-level (core.excludesFile, personal to your machine), and .git/info/exclude (per-clone, never committed, useful for one-off local-only ignores).

Related tools

Last updated · E-Utils editorial team