# Glob and .gitignore tester

Test glob patterns and .gitignore rules against a list of paths and see which paths match and which rule matched them.

https://codeknife.dev/en/glob-tester/

## What it does

Tests glob patterns and `.gitignore` rules against a list of paths. Each path is marked as matching or not, with the pattern responsible next to it, so you can see why `src/lib/util.test.ts` is in or out.

## How to use it

1. Paste one path per line, or drop a text file, into **Paths**.
2. Write one pattern per line in **Patterns**. Lines that start with `#` are comments.
3. Pick **Glob**, **Bash** or **Gitignore**, and show all paths, only the matches or only the misses.
4. Copy the result.

## Examples

With the patterns `src/**/*.ts` and `!**/*.test.ts`, the path `src/lib/util.ts` matches and `src/lib/util.test.ts` does not, because the exclusion wins. With the `.gitignore` rules `*.log` and `!keep.log`, `app.log` is ignored and `keep.log` is not.

## Good to know

- `*` stays inside one directory, `**` crosses directories, and `?`, `[ab]` and `{a,b}` work as in picomatch.
- Dotfiles such as `.env` only match when you turn on **Match dotfiles** or the pattern names the dot.
- In Glob and Bash a pattern that starts with `!` excludes what the other patterns matched. In Gitignore the last matching rule wins, as in Git.
- Bash reads `**` as a plain `*`, like a shell without `globstar`.
- Paths are matched as text. Nothing is read from a disk.

## What do the three syntaxes mean?

Glob is the picomatch syntax most build tools use: * stays inside one directory, ** crosses directories, and braces like {a,b}, classes like [ab] and ? work too. Bash reads ** as a plain *, as a shell does without globstar. Gitignore follows .gitignore rules: a trailing / means a directory, a leading / anchors to the root, and a later ! rule re-includes what an earlier rule ignored.

## Frequently asked questions

### Which rule is shown next to a path?

The first pattern that matched it. In glob and bash, a path that an exclusion (a pattern starting with !) removes shows that exclusion. In gitignore, the rule that ignored it is shown.

### Why does * not match a file that starts with a dot?

Globs skip dotfiles unless the pattern names the dot. Turn on Match dotfiles to let * and ? match them, like bash dotglob. A .gitignore has no such switch.

### Does this tool send my paths anywhere?

No. Everything happens in your browser. What you type is never sent to our servers.