Generate .gitignore files from presets for Node, Python, Java, Go, Rust, macOS, Windows and editors. Keep artifacts and secrets out of Git.
Use this free online .gitignore Generator directly in your browser. No signup required, no data leaves your device. Part of Utilier — a collection of 133+ developer utilities.
What is .gitignore Generator?
A .gitignore file tells Git which files and directories to exclude from version control. It contains patterns that match filenames — when Git sees a file matching a .gitignore pattern, it treats the file as untracked and never stages, commits, or pushes it. This tool combines preset patterns for languages, operating systems, and editors into a ready-to-use .gitignore.
Preset library: Pre-built patterns for Node.js, Python, Java, Go, Rust, and other languages; macOS and Windows OS files; and VS Code and JetBrains editor configs. Select multiple presets and they merge into one file.
Language-specific patterns: Node preset ignores node_modules/, .env, dist/. Python preset ignores __pycache__/, *.pyc, .venv/. Each preset covers the common build artifacts, dependencies, and generated files for that language.
OS cruft elimination: macOS creates .DS_Store, .AppleDouble, and .Trashes in every folder. Windows creates Thumbs.db and Desktop.ini. The OS presets ensure these never appear in commits.
Editor config exclusion: VS Code creates .vscode/ folders, JetBrains IDEs create .idea/ and *.iml files. The editor presets prevent personal IDE settings from being shared across the team.
Copy-paste ready: The output is a valid .gitignore file with one pattern per line. Copy it and paste directly into your repository's .gitignore.
Why use gitignore generator?
Every repository needs a .gitignore to prevent polluting version control with build artifacts, secrets, and personal configs. Writing one from scratch means Googling patterns, missing edge cases, and discovering unwanted files in commits after it is too late.
Keep secrets out of commits: .env files, API keys, credentials, and tokens should never be committed. Node and Python presets include .env*, *.key, and common secret file patterns.
Avoid committing dependencies: node_modules/ (Node), venv/ (Python), vendor/ (Go, PHP) are generated directories that bloat the repository and cause merge conflicts. Presets exclude them automatically.
Prevent OS noise: .DS_Store on macOS, Thumbs.db on Windows — these OS-generated files add no value to the repository and cause confusion. OS presets eliminate them.
Keep IDE configs personal: Your team uses VS Code, IntelliJ, Vim, and Emacs. Each IDE creates config folders (.vscode/, .idea/). Ignoring them means no config file wars in pull requests.
Reduce repository size: Build outputs (dist/, target/, *.class) are large and regenerated by every developer. Excluding them keeps the repository small and clone times fast.
Avoid unnecessary merge conflicts: If package-lock.json, Cargo.lock, or *.pyc files are committed, every dependency update creates conflicts. Ignoring generated files prevents this.
Start projects correctly: Add a .gitignore before the first commit. Much easier than removing files from history later (git rm --cached is tedious).
When to use gitignore generator
Use whenever you initialize a new repository or add a new language or tool to an existing project.
Creating a new repository for a Node, Python, Java, Go, or Rust project and need the standard ignore patterns.
Adding .gitignore to an existing project that does not have one (before files are committed).
Expanding a .gitignore when you add a new language or framework (e.g., adding Python to a Node project).
Standardizing .gitignore across multiple projects or a monorepo.
Auditing an existing .gitignore to see which common patterns are missing.
Learning which files should be ignored for a language you are new to.
Preventing OS files (.DS_Store, Thumbs.db) from appearing in commits on multi-OS teams.
How to use gitignore generator
Select presets, generate the .gitignore, and copy it to your repository.
Select language presets: Check the boxes for languages in your project: Node, Python, Java, Go, Rust, etc. If multiple languages are used (e.g., Node + Python), select all of them. Patterns are merged with duplicates removed.
Select OS presets: If your team uses macOS, Windows, or both, select the corresponding OS presets. This excludes .DS_Store, Thumbs.db, and other OS cruft from commits.
Select editor presets: If most of the team uses VS Code, JetBrains, or other IDEs, select those presets to ignore .vscode/, .idea/, and editor-specific config files.
Preview the output: The generated .gitignore appears in the output pane. Each selected preset contributes its patterns, and duplicates are removed. Review the list to ensure it covers your needs.
Copy or download: Use the Copy button to copy the .gitignore content, or Download to save it as a .gitignore file. Paste or move it to the root of your repository.
Commit the .gitignore: Run 'git add .gitignore && git commit -m "Add .gitignore"' before adding any other files. This ensures ignored files never enter version control.
Add custom patterns: If the presets do not cover all your needs, manually add patterns (e.g., logs/, *.tmp) to the .gitignore file after pasting.
Key features
Multi-preset merging: Select multiple presets (Node + Python + macOS + VS Code) and they merge into one .gitignore with duplicates removed.
Language coverage: Presets for Node.js, Python, Java, Go, Rust, and more. Each covers build directories, dependency folders, and common generated files.
OS file exclusion: macOS (.DS_Store, .AppleDouble, .Trashes) and Windows (Thumbs.db, Desktop.ini) presets eliminate OS cruft.
Editor config patterns: VS Code (.vscode/), JetBrains (.idea/, *.iml) presets prevent IDE settings from polluting commits.
Copy and download: Copy the .gitignore text directly or download as a .gitignore file ready to place in your repository root.
Instant preview: See the generated .gitignore update in real-time as you select presets.
Common use cases
New repository setup: Initialize a .gitignore before the first commit to prevent build artifacts and dependencies from ever being committed.
Multi-language projects: Combine Node + Python or Java + Go presets for projects that use multiple languages.
Cross-OS teams: Add macOS and Windows presets so .DS_Store and Thumbs.db never appear in pull requests.
IDE diversity: Include VS Code and JetBrains presets when team members use different editors.
Standardization: Generate identical .gitignore files for multiple microservices or monorepo packages.
Learning: See which files should be ignored for a language or framework you are new to.
Adding .gitignore after files are already committed
Why it happens: Git only ignores untracked files. If node_modules/ or .env is already committed, adding those patterns to .gitignore has no effect — the files remain tracked and appear in diffs and commits. This is a common trap: you add .gitignore, commit it, and wonder why ignored files are still showing up in 'git status'.
How to avoid it: Create and commit .gitignore before adding any code. If files are already tracked, remove them from Git's index with 'git rm --cached <file>' or 'git rm -r --cached <directory>', then commit the removal. The files stay on disk (--cached) but Git stops tracking them. Future changes to those files will be ignored.
Committing .env files or API keys
Why it happens: .env files contain secrets: database passwords, API keys, OAuth tokens. If committed to a public repository, those secrets are exposed to anyone who clones the repo or browses the commit history — even if you delete the file later, it remains in Git history. Scrapers constantly scan GitHub for leaked keys and exploit them within minutes.
How to avoid it: Add .env, .env.local, .env.production, *.key, and secrets/ to .gitignore before the first commit. The Node preset includes .env* patterns. If a secret was already committed, immediately rotate the key (invalidate the old one, issue a new one), remove the file from history with 'git filter-branch' or BFG Repo-Cleaner, and force-push. Do not just delete the file — it stays in history.
Forgetting to ignore OS files on cross-platform teams
Why it happens: macOS creates .DS_Store in every folder, Windows creates Thumbs.db. If these are not ignored, they appear in every pull request, cause merge conflicts, and clutter the commit history. Developers on the other OS do not have those files, so they show up as untracked in 'git status' and confuse everyone.
How to avoid it: Always add macOS and Windows presets to the .gitignore if your team uses both. Even if you personally use macOS, your collaborators might use Windows. The presets are small and harmless if the OS is not present.
Why it happens: Lock files pin exact dependency versions so every developer and CI environment gets the same builds. If ignored, each developer might get different versions, causing 'works on my machine' bugs. For libraries (npm packages), it is conventional to ignore lock files. For applications (deployed services), lock files must be committed.
How to avoid it: For applications (services you deploy), commit lock files. For libraries (published packages), add package-lock.json to .gitignore. The Node preset does not ignore lock files by default because applications need them. If you are building a library, manually add package-lock.json to your .gitignore.
Using .gitignore for sensitive files that were already committed
Why it happens: If config/database.yml or secrets.txt was committed weeks ago, adding it to .gitignore today does not remove it from history. The file is in every clone, every checkout, every branch. Anyone with access to the repository can browse old commits and retrieve the file. .gitignore only prevents future commits, not past ones.
How to avoid it: Remove sensitive files from Git history entirely. Use 'git filter-branch --tree-filter "rm -f <file>" HEAD' or BFG Repo-Cleaner (faster). Then force-push with 'git push --force'. Rotate any secrets that were exposed (assume compromised). For the future, use a .gitignore template before the first commit.
Frequently asked questions
How do I use a .gitignore file in my repository?
Create a file named .gitignore (with the leading dot) in the root of your repository. Paste the generated patterns into it, one pattern per line. Commit the .gitignore file: 'git add .gitignore && git commit -m "Add .gitignore"'. Git will now ignore files matching those patterns. Make sure to add the .gitignore before committing any files you want ignored.
Why are files still tracked even after I added them to .gitignore?
.gitignore only affects untracked files. If a file was already committed before you added it to .gitignore, Git continues tracking it. To stop tracking it, run 'git rm --cached <file>' (removes from Git but keeps the file on disk), then commit the change. Future modifications to that file will be ignored.
Should I commit package-lock.json, Cargo.lock, or Gemfile.lock?
For applications (web apps, services you deploy), yes — commit lock files to ensure consistent dependency versions across environments. For libraries (npm packages, Rust crates you publish), no — ignore lock files so consumers use the latest compatible versions. The Node preset does not ignore package-lock.json because most projects are applications.
Can I have multiple .gitignore files in subdirectories?
Yes. Git supports .gitignore files in any directory. Patterns in a subdirectory .gitignore apply relative to that directory. This is useful for monorepos: /backend/.gitignore has Node patterns, /frontend/.gitignore has different patterns. The root .gitignore handles global OS and editor patterns.
How do I un-ignore a file that matches a pattern?
Use the ! prefix to negate a pattern. For example, if you ignore all .log files with *.log, you can un-ignore one specific file with !important.log. The negation must come after the ignore pattern in the .gitignore file.
What is the difference between .gitignore and .dockerignore?
.gitignore tells Git which files to exclude from version control (commits). .dockerignore tells Docker which files to exclude from the build context (when running 'docker build'). They often overlap (node_modules/, .env), but .dockerignore might also exclude .git/, README.md, and tests/ that are in version control but not needed in the Docker image.
Should I commit .env.example or .env.template?
Yes. .env contains real secrets and should be ignored. .env.example or .env.template contains variable names with placeholder values (DB_PASSWORD=your_password_here) and should be committed. It documents which environment variables the app needs without exposing real credentials.