Git .gitignore Templates Directory
Curated, battle-tested `.gitignore` templates for every major programming language, web framework, operating system, and cloud tool. Keep repository sizes slim, eliminate merge conflicts, and prevent leaking secret credentials.
Node.js .gitignore Template
Standard .gitignore for Node.js, npm, yarn, and pnpm projects. Ignores dependencies, runtime logs, build output, and local environment files.
Python .gitignore Template
Comprehensive Python .gitignore ignoring bytecode (__pycache__), virtual environments (venv, .venv), distribution builds, and test artifacts.
React & Next.js .gitignore Template
Tailored .gitignore for Next.js and React web apps. Ignores .next build caches, static exports, Vercel deployments, and local env variables.
Go (Golang) .gitignore Template
Clean .gitignore for Go projects ignoring compiled architecture binaries, coverage profiles, and local vendor folders.
Rust & Cargo .gitignore Template
Standard .gitignore for Rust projects ignoring the entire /target directory and debug symbol files.
Java (Maven & Gradle) .gitignore Template
Standard .gitignore for Java applications built with Apache Maven or Gradle, ignoring target and build directories.
macOS System Files (.DS_Store) .gitignore Template
Global .gitignore rules for Apple macOS files including .DS_Store, AppleDouble, Spotlight indexing, and icon metadata.
Visual Studio Code & JetBrains IDE .gitignore Template
Rules for editor configurations: ignores personal window state and workspace caches while allowing shared team settings.
Terraform .gitignore Template
Critical .gitignore for HashiCorp Terraform preventing cloud credential leaks (.tfstate, .tfvars) and ignoring provider cache.
Docker (.dockerignore) Template
Essential .dockerignore template to speed up docker build context, reduce image size, and prevent leaking .git and .env into container images.
.gitignore Pattern Syntax Cheatsheet
Mastering glob patterns, directory matching, and rule negations
| Pattern | Matching Behavior | Example Matches |
|---|---|---|
| node_modules/ | Matches directory only (and all contents recursively) | Any folder named node_modules at any depth |
| *.log | Wildcard matching any file ending in .log | error.log, debug.log, npm-debug.log |
| /build | Leading slash pins match strictly to the repository root | Matches /build, but ignores /packages/api/build |
| **/temp | Double asterisk matches zero or more leading directories | temp, a/temp, a/b/c/temp |
| !important.log | Exclamation mark negates ignore rule (forces file tracking) | Re-includes important.log even if *.log is ignored |
Frequently Asked Questions About .gitignore Files
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
Git continues tracking files that were already committed before the .gitignore rule was added. To untrack them without deleting your local files, run: `git rm -r --cached . && git add . && git commit -m "Untrack ignored files"`.