.gitignore Generator
Generate .gitignore files for any project. Select your languages, frameworks, and IDEs to create a comprehensive .gitignore instantly.
Languages
Frameworks
IDEs
OS
Tools
# Select templates above to generate your .gitignore fileHow to Use
- Search or browse templates by category — Languages, Frameworks, IDEs, OS, and Tools.
- Select every template that applies to your project by clicking the checkbox next to each name.
- Review selected templates in the pills section. Click the × to remove any you don't need.
- Preview the combined
.gitignoreoutput below. Duplicate patterns across templates are automatically removed. - Click Copy to copy the contents to your clipboard, or Download .gitignore to save the file directly.
What Is a .gitignore File?
Every Git repository can include a special file called .gitignore that tells Git which files and directories to exclude from version control. Without it, Git would track everything in your project directory — including generated build artifacts, dependency folders with thousands of files, IDE configuration, OS metadata, and potentially sensitive files like .env containing API keys and passwords.
A well-crafted .gitignore keeps your repository clean, reduces clone and fetch times, avoids merge conflicts on generated files, and prevents accidental exposure of secrets. It's one of the first files you should create in any new project.
Pattern Syntax
Gitignore patterns use a simplified glob syntax. Here are the most important rules:
*— matches any characters except a forward slash (/)**— matches directories at any depth (e.g.,**/logsmatcheslogs,src/logs,a/b/logs)?— matches exactly one character[abc]— matches any single character in the bracketsdir/— a trailing slash means "only match directories"/file— a leading slash anchors the pattern to the repository root!pattern— negates a previous ignore rule, re-including the matched files#— lines starting with#are comments
For example, *.log ignores all log files everywhere, while /debug.log ignores only debug.log in the root directory. The pattern build/ ignores any directory named build, and doc/**/*.pdf ignores all PDF files under the doc/ directory at any depth.
Global vs. Local .gitignore
Git supports three levels of ignore rules:
- Repository .gitignore — the standard
.gitignorefile at the project root (and optionally in subdirectories). Committed to the repo and shared with all collaborators. - Global .gitignore — a personal file (typically
~/.gitignore_global) that applies to every repository on your machine. Set it up withgit config --global core.excludesfile ~/.gitignore_global. Ideal for OS files (.DS_Store,Thumbs.db) and IDE files (.idea/,.vscode/) that are specific to your setup. - .git/info/exclude — a per-repository exclude file that isn't committed. Useful for personal ignores that shouldn't affect other developers.
Best practice: put OS and IDE patterns in your global gitignore, and language/framework-specific patterns in the project's .gitignore. That way your teammates aren't forced to adopt your editor's ignore rules, and you don't clutter every project with the same OS-specific entries.
Common Mistakes
The most frequent .gitignore mistakes developers encounter:
- Adding .gitignore after files are already tracked — Gitignore only prevents untracked files from being added. If a file is already committed, adding it to
.gitignorewon't remove it. Rungit rm --cached <file>first. - Forgetting to ignore .env files — Environment files containing API keys, database passwords, and secrets should always be in
.gitignore. Commit a.env.examplefile instead with placeholder values. - Ignoring lock files incorrectly — Files like
package-lock.json,yarn.lock, andGemfile.lockshould generally be committed (they ensure reproducible builds). OnlyCargo.lockis typically ignored for library crates. - Using overly broad patterns — A pattern like
*.jsoncould accidentally ignore configuration files you need tracked. Be specific:coverage/*.jsonis safer than*.json. - Not testing patterns — Use
git check-ignore -v <file>to verify which rule is causing a file to be ignored. Usegit status --ignoredto see all ignored files.
How Git Processes .gitignore
Git evaluates ignore patterns from multiple sources in a specific order: patterns from the command line, patterns from the .gitignore in the same directory, then parent directories up to the repository root, then the global gitignore, and finally .git/info/exclude. Within each file, later patterns override earlier ones. A negation pattern (!) can re-include a file excluded by an earlier rule, but it cannot re-include a file inside an ignored directory.
Understanding this precedence is important when debugging why a file is or isn't being ignored. The git check-ignore -v command is invaluable — it shows exactly which file and line number is responsible for ignoring a given path.
Related Tools
Look up Git commands with the Git Command Reference. Compare file versions with the Diff Checker. Compare environment files with .env Diff. Test gitignore glob patterns with the Regex Tester.
Frequently Asked Questions
- What is a .gitignore file?
- A .gitignore file tells Git which files and directories to ignore in a project. Ignored files won't appear in git status, won't be staged with git add, and won't be committed. It's essential for keeping build artifacts, dependency folders, and secrets out of version control.
- Where should I put the .gitignore file?
- Place the .gitignore file in the root directory of your Git repository. Git also supports .gitignore files in subdirectories — patterns in those files apply only to files within that directory and its children. You can also configure a global gitignore file for patterns you want ignored in every repository on your machine.
- How do glob patterns work in .gitignore?
- Gitignore uses glob patterns: * matches any characters except /, ** matches directories at any depth, ? matches a single character, and [abc] matches any character in the brackets. A trailing slash (e.g., build/) matches only directories. A leading slash anchors the pattern to the .gitignore file's directory. A leading ! negates a pattern, re-including a previously excluded file.
- Why are my ignored files still being tracked?
- If a file was already tracked by Git before you added it to .gitignore, Git will continue tracking it. You need to remove it from the index with "git rm --cached filename" (which keeps the local file but removes it from tracking), then commit. After that, the .gitignore rule will take effect.
- Can I combine multiple templates in one .gitignore?
- Yes — that's exactly what this tool does. Most real projects need multiple templates: a language (Node.js, Python), an IDE (VS Code, JetBrains), and an OS (macOS, Windows). This generator deduplicates overlapping patterns and organizes the output with section headers for clarity.
- Is there a global .gitignore for all my projects?
- Yes. Run "git config --global core.excludesfile ~/.gitignore_global" to set a global gitignore file. Add OS-specific patterns (like .DS_Store for macOS or Thumbs.db for Windows) and IDE patterns there, so you don't need to repeat them in every project.
AI agent tools available.
The CodeTidy MCP Server gives Claude, Cursor, and other AI agents
access to 47 developer tools. One command: npx @codetidy/mcp