igittigitt

igittigitt is a spec-compliant .gitignore parser for Python - a library and a
command-line tool. Point it at .gitignore rules (or pass rules as strings) and ask
whether a path is ignored, or use it directly as the ignore= callback of
shutil.copytree.
Features
- 100% git-compatible matching. The matching engine reproduces git's algorithm
exactly - a single ordered pass with last-matching-pattern-wins, correct
negations (
!pattern), the rule that a file cannot be re-included when a parent
directory is excluded, per-directory .gitignore precedence, anchors, trailing-slash
(directory-only), ** (a segment of three or more asterisks such as ***/build counts
as ** too, as in git), *, ? and [...] character classes. Compatibility is
proven by a differential test suite that compares igittigitt against real git check-ignore on hundreds of generated cases. (This fixes the negation and
nested-precedence limitations of older releases.)
- Include / whitelist mode.
IncludeParser inverts the
logic: patterns describe what to keep. It is directory-aware (rsync-like), so it
works correctly as a copytree filter even for deeply nested includes.
- Memory-safe for millions of files. Both modes stream per directory. Memory scales
with the number of rules, never with the number of files or directories - so it stays
flat on trees with millions of entries.
- Fast with large
.gitignore templates. Like git, a pattern without a slash (*.pyc,
node_modules, __pycache__) is decided by the path's last segment alone, through a
dictionary lookup, so most rules are never run as a regular expression. Rule-file
discovery does not walk into directories the rules exclude.
- Scriptable CLI with piping.
igittigitt check mirrors git check-ignore, and
igittigitt filter is a Unix filter that reads paths from stdin and prints the
survivors - newline- or NUL-separated (-z), streamed, with clean SIGPIPE handling, so
it drops cleanly into find ... | igittigitt filter.
- Typed library, pure Python. Ships
py.typed, no runtime dependency on the git
binary.
Comparison
How igittigitt compares with the two other Python libraries for .gitignore matching,
pathspec and
gitignore_parser. Measured in November 2026 with
igittigitt 2.6.0, pathspec 1.1.1 and gitignore_parser 0.1.13.
Features