PureDevTools

GitHub .gitignore Generator

Generate .gitignore files for any technology stack — combine templates, add OS & IDE patterns, write custom rules

All processing happens in your browser. No data is sent to any server.

Select Technologies

Common Additions

Frequently needed patterns that are independent of any specific technology.

Custom Patterns

Generated .gitignore
Select at least one technology or add custom patterns to generate your .gitignore file.

You git init a new project and make your first commit. Two minutes later you realize you just committed node_modules/ (50,000 files), .env with your database password, and .DS_Store. You git rm --cached them all, add a .gitignore, and commit again — but the .env is still in your Git history. This happens because .gitignore only prevents future tracking; it doesn’t undo what’s already committed. The fix is to create the .gitignore before your first commit.

Why This Generator (Not gitignore.io or GitHub Templates)

GitHub’s template .gitignore files cover one language at a time. gitignore.io combines templates but its output can be overwhelming — 200+ lines for a Node.js + macOS + VS Code combination. This tool lets you select from 35+ technology templates, combine them, add OS and IDE patterns, write custom rules, and see the final result — without scrolling through patterns you don’t need. Everything runs in your browser; no data is sent anywhere.

What Is a .gitignore File?

A .gitignore file tells Git which files and directories to exclude from version control. It lives at the root of your repository and uses glob patterns to match paths that should never appear in commits, pull requests, or repository history.

Every project has files that should not be tracked: compiled binaries, dependency directories, environment secrets, build artifacts, and editor-specific configuration. Without a proper .gitignore, these files pollute commits, slow down clones, and risk leaking sensitive credentials.

This tool generates a complete .gitignore file from 35+ technology templates. Select any combination of languages, frameworks, operating systems, IDEs, and tools — then copy the result directly into your project.


How to Use This Tool

  1. Search or browse technologies — type in the search box to filter, or click a category tab (Languages, Frameworks, OS, IDEs, Tools).
  2. Select technologies — check one or more templates from the list. Each adds a labeled section to the output.
  3. Add common additions — check frequently needed patterns like .env files, OS system files, IDE directories, logs, and test coverage output.
  4. Add custom patterns — enter project-specific globs in the custom patterns editor, one per line.
  5. Copy the output — click Copy to copy the generated .gitignore to your clipboard, then paste it into your project root.

All processing happens in your browser. Nothing is sent to a server.


Pattern Syntax

Git ignores files using glob patterns. Understanding the syntax helps you write effective custom patterns:

PatternWhat it ignores
node_modules/Directory named node_modules anywhere in the tree
*.logAll files ending in .log
!important.logException — do NOT ignore important.log
build/Directory named build
**/temp/Directory named temp at any depth
/dist/Only the dist/ at the repository root (not subdirectory dist/)
doc/*.txtAll .txt files directly inside doc/ (not deeper)
doc/**/*.txtAll .txt files anywhere under doc/

Key rules:


Language Templates

Node.js

The Node.js template excludes node_modules/ (the package dependency cache), build outputs (dist/, build/), log files, npm/yarn/pnpm debug logs, process ID files, and TypeScript incremental build info (.tsbuildinfo). It also excludes Yarn’s offline cache directories and .eslintcache.

Never commit node_modules/. Packages can be fully restored by running npm install from package.json, and the directory often contains thousands of files that inflate repository size dramatically.

Python

The Python template excludes __pycache__/ directories and .pyc compiled bytecode, virtual environment directories (.venv/, venv/, env/), distribution packaging artifacts (dist/, build/, *.egg-info/), test framework caches (.pytest_cache/, .tox/), coverage reports (htmlcov/, .coverage), mypy type-check cache (.mypy_cache/), and Jupyter Notebook checkpoints.

Java

The Java template excludes compiled .class files, JAR/WAR/EAR build artifacts, Gradle cache (.gradle/), and Maven wrapper binaries. The target/ and out/ build directories are excluded while keeping Gradle wrapper JARs (via !gradle-wrapper.jar).

Go

Go binaries are named without extension on Unix and with .exe on Windows — the template excludes both. It also excludes .test binaries (from go test -c), vendor/ (when using dependency vendoring), and go.work workspace files.

Rust

Rust’s Cargo build system places all output in target/. The template excludes this directory along with *.rs.bk rustfmt backup files and .pdb debugging symbol files from MSVC builds. Cargo.lock is intentionally not excluded — keep it for binary/application crates, but libraries conventionally do not commit it.

C++

The C++ template covers compiled object files (.o, .obj), precompiled headers (.gch, .pch), static and shared libraries (.a, .lib, .so, .dll), executables (.exe, .out, .app), and CMake build artifacts (CMakeFiles/, CMakeCache.txt, cmake-build-*/).


Framework Templates

React / Next.js

React (Create React App) excludes the build/ output directory and .env.local, .env.*.local environment variable files. Next.js additionally excludes .next/ (the build cache), out/ (static export), .vercel, and next-env.d.ts (auto-generated TypeScript declarations).

Vue / Svelte

Vue projects exclude dist/ and .nuxt/ (for Nuxt.js projects). Svelte/SvelteKit projects exclude .svelte-kit/ (the framework cache directory) and build/.

Angular

Angular CLi projects exclude dist/, out-tsc/ (TypeScript compilation output), and /.angular/cache/ (Angular’s CLI cache). Bazel output (bazel-out/) is also excluded for teams using Bazel as a build system.

Django

Django projects should exclude db.sqlite3 (the development database), __pycache__/, media/ (user-uploaded files), staticfiles/ (collected static files from collectstatic), and Celery task scheduler state files (celerybeat-schedule).

Laravel

Laravel projects exclude the vendor/ Composer directory, public/hot (Laravel Mix hot reload socket), public/storage (symlinked storage), storage/*.key, and environment files. Laravel’s .env contains database credentials and application secrets — never commit it.

Ruby on Rails

Rails projects exclude the SQLite database files, log/ and tmp/ directories (while keeping the .keep placeholder files via negation patterns), public/system/, and Spring pre-loader state (.spring/).


Common Additions

Environment Files (.env)

The .env file and its variants (.env.local, .env.production, .env.development) contain database connection strings, API keys, OAuth secrets, and other sensitive credentials. These must never be committed to version control.

Add a .env.example file (tracked in Git) that lists all required variables with placeholder values, so developers know what to configure.

# .env.example — commit this
DATABASE_URL=postgres://user:password@localhost/mydb
API_KEY=your-api-key-here
SECRET_KEY=your-secret-key-here

OS System Files

macOS creates .DS_Store metadata files in every directory a user opens in Finder. These store icon positions and view settings — they are meaningless to other developers and should always be ignored. Windows creates Thumbs.db (thumbnail cache) and Desktop.ini (folder display settings).

IDE and Editor Files

Most IDE directories are personal preference and should not be committed. However, some teams choose to commit shared VS Code settings — the VS Code template uses negation patterns to keep settings.json, tasks.json, launch.json, and extensions.json while ignoring everything else in .vscode/.

JetBrains IDEs (IntelliJ IDEA, WebStorm, PyCharm, GoLand, RubyMine) store configuration in .idea/. Workspace files (.iws) are user-specific and should be ignored; module files (.iml) are debatable — some teams commit them.


Files You Should NOT Ignore

Some files are commonly mistaken as safe to ignore but should be committed:

FileWhy to commit it
package-lock.jsonLocks exact dependency versions for reproducible installs
yarn.lockSame as above for Yarn
Cargo.lockRequired for binary/application crates (reproducible builds)
Gemfile.lockLocks Ruby gem versions
go.sumCryptographic checksums for Go module versions
.gitignore itselfShared across all developers on the project
.env.exampleDocuments required environment variables without secrets
gradle-wrapper.jarEnsures everyone uses the same Gradle version

Fixing Already-Tracked Files

Adding a pattern to .gitignore only prevents future tracking. Files already committed remain tracked. To stop tracking a committed file:

# Stop tracking a single file (keep it locally)
git rm --cached path/to/file

# Stop tracking a directory (keep it locally)
git rm -r --cached path/to/directory/

# Commit the removal
git commit -m "chore: stop tracking generated files"

After this commit, Git ignores the file even without the --cached flag.


Global .gitignore

A global .gitignore applies to all repositories on your machine — useful for OS and editor files that are truly personal preferences:

# Set up a global .gitignore
git config --global core.excludesfile ~/.gitignore_global

Put macOS .DS_Store, Windows Thumbs.db, JetBrains .idea/, and VS Code .vscode/ patterns here so you do not need to add them to every project’s .gitignore.


Frequently Asked Questions

Q: What is a .gitignore file? A: A .gitignore file tells Git which files and directories to exclude from tracking. It uses glob patterns to match paths that should not appear in commits — dependencies, build outputs, secrets, and OS/editor files.

Q: Where should I put the .gitignore file? A: In the root directory of your repository. You can also create .gitignore files in subdirectories — they apply to that directory tree. A global ~/.gitignore_global applies across all repositories on your machine.

Q: Can I combine multiple templates? A: Yes. Select any number of technologies. Each adds its own labeled section to the .gitignore. Combining Node.js + React + macOS + VS Code is a typical full-stack JavaScript setup.

Q: Should I commit node_modules? A: Never. It contains thousands of files that are fully regenerated by npm install. Committing it bloats repository size, causes conflicts, and slows every git operation.

Q: How do I ignore files already tracked by Git? A: Run git rm --cached <file> to stop tracking the file while keeping it locally, then commit the removal. After that, the .gitignore pattern takes effect.

Q: What is .gitkeep? A: An informal convention — an empty file placed inside an empty directory to force Git to track it (Git ignores empty directories). Any file name works, but .gitkeep is the convention. It has nothing to do with .gitignore.

Q: Is my data sent to a server? A: No. All .gitignore generation happens entirely in your browser. No data is sent anywhere.

Related Tools

More Code & Config Generators