Skip to content

Gitignore builder

Combine project presets and custom rules with a local path-matching preview and downloadable ignore content.

Custom patterns
One relative path per line. End directory paths with /.
Ignore rule preview
Generated .gitignore content
# Node.js
node_modules/
dist/
coverage/
.next/
*.log
.env
.env.*
!.env.example

# macOS
.DS_Store
._*
PathResultRule
node_modules/package/index.jsIgnorednode_modules/
src/index.jsIncludedNo matching rule
.envIgnored.env
.env.exampleIncluded!.env.example
.DS_StoreIgnored.DS_Store

10 rules. Export contains every rule; sample paths are only a preview.

Processed on your device

How it works & useful details

How it works & supported syntax

Combine small editable starter presets with custom rules for one root .gitignore. The local path preview supports literals, *, ** as a complete path segment, ?, /, comments and ! negation. Character classes and backslash escapes are unsupported. Last matching rules win; excluded parent directories cannot be bypassed by a child negation.

Only untracked paths are affected by Git ignore rules. This tool does not inspect your repository or other ignore sources. Up to 100 rules and 30 sample paths. The download is named gitignore.txt; save or rename it to .gitignore in your project root.

Local workspace

Your input stays in this page. These tools calculate or process text; they do not run commands, start containers, contact servers or change settings on your device.

Previews pause above 20,000 combined characters. Use the action to process the full supported input. Exports contain the complete result within the tool’s stated limits.

About this tool

Gitignore builder combines project presets with your own rules and previews which sample paths would be ignored. Checking the match result locally avoids the usual confusion about negation rules and directory patterns.

The generated file is text; nothing is written to your repository. Presets are starting points, and you can edit or extend every rule.

How to use it

  1. Select the presets that match your stack.
  2. Add or edit custom rules for your project.
  3. Check the path-matching preview for expected and unexpected matches.
  4. Download or copy the finished .gitignore content.

Worked example

The Node.js and macOS presets produce rules such as node_modules/, dist/, .env, .env.*, !.env.example, and .DS_Store. The path preview shows how they apply:

node_modules/package/index.js   ignored   (node_modules/)
src/index.js                    included  (no matching rule)
.env                            ignored   (.env)
.env.example                    included  (!.env.example)
.DS_Store                       ignored   (.DS_Store)

The ! rule re-includes the example environment file after .env.* excluded it. The last matching rule wins.

Gitignore rules in brief

  • name matches a file or directory with that name anywhere in the tree.
  • name/ matches directories only.
  • /name matches only at the repository root.
  • * matches anything except /, and ** matches across directories, as in logs/**/*.log.
  • !pattern re-includes something an earlier rule excluded, unless its parent directory is excluded.

Ignore rules only affect untracked files. If a file such as .env was committed before it was ignored, Git keeps tracking it. Remove it from the index with git rm --cached .env, and rotate any secret it contained, since it remains in the history. Save the download as .gitignore in the project root.

Frequently asked questions

Why is a file not ignored despite a matching rule?

Git evaluates rules in order and a later negation can re-include a path. The preview shows the resolved match so you can reorder rules.

Does this change my repository?

No. It only generates the ignore content; you decide where to place the file and when to commit it.

Does it cover global gitignore settings?

No. User-level and global ignore files live outside the project and are not part of this builder.

Should I commit .gitignore?

Yes. It belongs in the repository so everyone ignores the same files. Personal editor or OS files can go in a global gitignore (core.excludesFile) instead.