.gitignore Generator
Select your technologies and generate a .gitignore file instantly
Select one or more technologies above to generate your .gitignore file.๐ No upload โ runs entirely in your browser. Your data never leaves your device.
Related Tools
Robots.txt Generator
Generate robots.txt files with presets for AI crawlers and SEO.
JSON Formatter
Format, validate and minify JSON with error detection.
cURL to Code
Convert cURL commands to Python, JavaScript, Go and more.
Hash Generator
Generate SHA-1, SHA-256 and SHA-512 cryptographic hashes.
What is a .gitignore File?
A .gitignore file is a plain text file placed in the root of your Git repository that instructs Git which files and directories to skip when tracking changes. When you run git status, git add, or git commit, Git silently ignores anything matching a pattern in this file. The ignored files stay on your local machine but never make it into your repository's history.
Without a .gitignore file, every file in your project directory appears as an untracked file when you run git status. Developers then accidentally commit build output, API keys, operating system metadata, and hundreds of megabytes of third-party libraries โ things that pollute history, slow down clones, and in the case of secrets, create security vulnerabilities that can never be fully undone.
The .gitignore format is simple, flexible, and supported by every Git client and hosting platform including GitHub, GitLab, and Bitbucket. Every project, from a weekend side project to a production monorepo, should have a thoughtfully crafted .gitignore tailored to its specific stack โ which is exactly what this generator helps you create in seconds.
How to Use This .gitignore Generator
- 1.Select your technologies from the grid above. Use the search box to find a specific language, framework, or editor quickly, or click a category pill to filter by type.
- 2.Select multiple technologies freely โ a full-stack project might combine Node.js + React + VS Code + macOS, for example. Each template's content is appended with a clear comment header.
- 3.Review the generated output in the preview panel. The content updates instantly as you select or deselect technologies.
- 4.Click Download .gitignore to save the file directly, or Copy to paste it manually.
- 5.Place the file named exactly
.gitignorein your project root โ the same directory that contains your.git/folder. Then rungit statusto confirm the excluded files no longer appear as untracked. Commit the .gitignore file itself so your whole team benefits from the same rules.
For most projects, you will want to pick at least one language template, one IDE template, and your OS template. This three-layer approach covers: language-specific build artifacts (node_modules/, __pycache__/), editor configuration files (.idea/, .vscode/), and OS metadata files (.DS_Store, Thumbs.db).
Understanding .gitignore Syntax: Key Patterns Explained
Git uses a simplified glob pattern syntax for .gitignore rules. Understanding the rules prevents accidental over-ignoring or under-ignoring.
*.logโ A pattern with no slash matches files of that name anywhere in the entire repository tree. This ignores every .log file in every subdirectory.dist/โ A trailing slash indicates a directory. Git ignores the dist/ directory and everything inside it, but not a file literally named "dist" (without a slash)./build.shโ A leading slash anchors the pattern to the repository root. This only ignores build.sh at the root level, not at src/scripts/build.sh.!important.logโ An exclamation mark negates a pattern, un-ignoring files that an earlier rule would match. If you have*.logabove and!important.logbelow it, important.log will be tracked normally.**/tempโ Double asterisk matches any number of path segments. This ignores any file or directory named "temp" anywhere in the repository, regardless of depth.src/**/*.test.jsโ Combined wildcards are powerful. This ignores all .test.js files anywhere under the src/ directory.[Dd]ebug/โ Square brackets match any of the enclosed characters. This matches both "Debug/" and "debug/" โ useful for case-insensitive matching on systems that differ in filename case sensitivity.
One important ordering rule: if a parent directory is ignored, Git never checks patterns for files inside it โ even a negation pattern cannot un-ignore a file inside an already-ignored directory. To override an ignored parent, you would need to also un-ignore the parent itself.
Global .gitignore vs. Project .gitignore: Which to Use
Git supports two levels of ignore rules: project-level (the .gitignore in your repository) and global (a machine-wide file for personal tooling preferences). Knowing when to use each keeps your repository clean and your ignore rules maintainable.
Project .gitignore lives in your repository and is committed alongside your code. It contains patterns relevant to the entire team: language artifacts (node_modules/, __pycache__/), framework build output (dist/, .next/), environment files (.env), and secrets. Because every collaborator clones this file, it ensures consistent ignore behavior across the team regardless of what editor or OS they use.
Global .gitignore(~/.gitignore_global) applies to every repository on your personal machine. Use it for personal tooling noise: .DS_Store (macOS Finder metadata), Thumbs.db (Windows Explorer thumbnails), .idea/ or .vscode/ (your IDE), .history/ (local file history extensions). These should not be in your project's .gitignore because not every collaborator uses the same editor or OS โ adding .DS_Store to a shared repository means Windows users see an unnecessary pattern, and the project file grows stale over time.
To configure a global gitignore, run: git config --global core.excludesfile ~/.gitignore_global. Then add your personal patterns to that file. The patterns take effect immediately in every repository on your machine without requiring a commit.
Why .gitignore Patterns Matter for Security
Accidentally committing a secret to a Git repository โ even for a few minutes before it is deleted โ is a serious security incident. Secrets committed to Git are typically leaked in three ways: the file's diff appears in commit history, secrets show up in git log -p output, and in public repositories, automated credential scanners like GitHub Secret Scanning and truffleHog find and report them within seconds of the push.
Removing a secret from the latest commit does not remove it from Git history โ every past commit still contains it. Complete removal requires rewriting history with git filter-repo and force-pushing, which disrupts collaborators and cannot guarantee the secret was not already cloned, cached, or archived.
Patterns to always include in every project's .gitignore:
.envand.env.*โ environment variable files containing API keys, database URLs, and OAuth secrets*.pem,*.key,*.p12โ private keys and certificatesconfig/secrets.yml,config/master.keyโ Rails and similar framework credential filesauth.json,credentials.jsonโ service account files for cloud providers
Layer your protection: use .gitignore to prevent accidental commits, use a secrets manager (AWS Secrets Manager, HashiCorp Vault, Doppler) for runtime injection, and use a pre-commit hook or detect-secrets to block commits that look like they contain credentials before they ever reach a remote.
Common .gitignore Patterns Explained by Language
Different ecosystems generate different categories of files. Here is why the most common patterns appear in each template:
- Node.js โ node_modules/
Every npm, Yarn, or pnpm install populates node_modules/ with thousands of files. A typical Next.js project has 30,000+ files in this directory. Committing it bloats repository size by hundreds of megabytes, creates cross-platform binary conflicts, and slows every git operation. Use package-lock.json, yarn.lock, or pnpm-lock.yaml to reproduce the exact dependency tree on any machine. - Python โ __pycache__/ and *.pyc
Python compiles .py source files to bytecode (.pyc) stored in __pycache__/ directories. These files are platform-specific (different Python versions produce incompatible bytecode) and fully regenerated on import. Committing them means constant merge conflicts and binary diffs that add no value to history. The .venv/ and venv/ directories are virtual environments containing Python itself and all installed packages โ always reproduce these withpip install -r requirements.txt. - Java โ target/ and *.class
Maven compiles Java source files (.java) into bytecode (.class) and packages them in the target/ directory. These files are architecture-specific and 100% reproducible by runningmvn clean package. Committing them makes your repository binary-heavy and causes spurious diffs on every build. - Go โ vendor/
Go modules support vendoring dependencies into a vendor/ directory so builds work without network access. While some teams commit vendor/ intentionally for reproducibility, most prefer the standard module cache (go.sumprovides the lockfile). The Rust equivalent is the target/ directory which can easily exceed 1 GB for larger Rust projects.
What Files Should Always Stay Out of Version Control
Regardless of your stack, these categories should be in every .gitignore:
- Secrets and credentials..env files, private keys (*.pem, *.key), service account JSON files, and any config file that contains a real password or token. Rotate immediately if accidentally committed.
- Build artifacts.dist/, build/, out/, target/, __pycache__/, *.class, *.o โ anything generated from source code is reproducible and belongs in your CI/CD pipeline, not in history.
- Dependency directories.node_modules/, vendor/, .venv/, Pods/ โ use the corresponding lockfile to reproduce these deterministically.
- IDE and editor metadata..idea/, .vscode/, *.suo, *.user โ personal to each developer's machine and tooling. Use a global gitignore for these.
- OS-specific files..DS_Store (macOS), Thumbs.db, desktop.ini (Windows), .directory (Linux/KDE) โ generated by the operating system and meaningless to other collaborators.
- Log and temporary files.*.log, npm-debug.log, *.tmp โ transient files that change on every run and add noise to your repository history.