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.gitignoreprecedence, anchors, trailing-slash (directory-only),**(a segment of three or more asterisks such as***/buildcounts as**too, as in git),*,?and[...]character classes. Compatibility is proven by a differential test suite that compares igittigitt against realgit check-ignoreon hundreds of generated cases. (This fixes the negation and nested-precedence limitations of older releases.) - Include / whitelist mode.
IncludeParserinverts the logic: patterns describe what to keep. It is directory-aware (rsync-like), so it works correctly as acopytreefilter 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
.gitignoretemplates. 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 checkmirrorsgit check-ignore, andigittigitt filteris 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 intofind ... | igittigitt filter. - Typed library, pure Python. Ships
py.typed, no runtime dependency on thegitbinary.
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
| igittigitt | pathspec | gitignore_parser | |
|---|---|---|---|
Reads nested per-directory .gitignore files |
yes (parse_rule_files) |
no: it reads no files, so you find every .gitignore, rebase its patterns onto its directory and combine them yourself |
no: one file per parser |
| Directory-aware include / whitelist mode | yes (IncludeParser) |
no: match_files keeps the matches (negate=True drops them), but parent directories are not kept |
no |
shutil.copytree filter |
yes | no | no |
| Command-line tool | yes | no | no |
| Matches without touching the disk | no: it checks each path's type | yes | yes |
Git compatibility
Checked against git check-ignore --no-index on thirteen cases chosen to probe known differences
(excluded parent directories, ***, a plain directory name, and whether a path counts as a
directory: git takes a path as a directory when it ends in / or is a directory on disk, never a
symlink to one). igittigitt matched git in all thirteen. The cases where another library differs:
| Rules | Path | git | igittigitt | pathspec | gitignore_parser |
|---|---|---|---|---|---|
.venv |
.venv/Lib/site-packages/m.py |
ignored | ignored | ignored | not ignored |
x/***/y |
x/y, x/a/b/y |
ignored | ignored | not ignored | ignored |
build/ then !build/keep.txt |
build/keep.txt |
ignored | ignored | not ignored | not ignored |
/a/ then !/a/b/ |
a/b/c.txt |
ignored | ignored | not ignored | ignored |
build/ |
build, a directory on disk |
ignored | ignored | not ignored | ignored |
logs/ |
logs, a file on disk |
not ignored | not ignored | not ignored | ignored |
gone/ |
gone, not on disk |
not ignored | not ignored | not ignored | ignored |
link/ |
link, a symlink to a directory |
not ignored | not ignored | not ignored | ignored |
The build/keep.txt and a/b/c.txt rows are git's rule that a file cannot be re-included when
a parent directory is excluded.
Speed and memory
One root .gitignore of 810 lines (GitHub's Python, Node and VisualStudio templates), a stream of
file paths as find -type f prints them, Python 3.13 on Linux, pinned to one CPU core. Each
figure is the median of three interleaved runs; gitignore_parser ran once, on the smaller set
only.
| Library | 105k files | 422k files | Peak memory | Compared with igittigitt |
|---|---|---|---|---|
igittigitt (IgnoreParser.match) |
1.35 s | 5.17 s | 29-31 MB | - |
| pathspec, pure-Python backend | 6.15 s | 25.34 s | 16 MB | 4.6-4.9x slower |
pathspec with google-re2 installed |
0.10 s | 0.37 s | 19 MB | 13-14x faster |
pathspec with hyperscan installed |
0.11 s | 0.44 s | 27 MB | 12x faster |
| gitignore_parser | 249 s | not run | 13 MB | about 185x slower |
All four pathspec and igittigitt runs ignored exactly the same files (90,386 of 105,416, and
361,919 of 421,961). gitignore_parser left 20,000 files inside a .venv directory unignored.
Peak memory did not grow from 105k to 422k files for igittigitt or pathspec, since the paths are
streamed rather than loaded into a list.
pathspec uses re2 or hyperscan automatically once one of them is installed, and falls back to
its pure-Python backend otherwise. As of November 2026, google-re2 publishes wheels for CPython
3.10 to 3.14 (none for 3.15), and hyperscan for CPython 3.10 to 3.15, both on Linux, macOS and
Windows. On a Python without a wheel, pip tries to build from source, which needs a C++ compiler
and the native library; for google-re2 on Python 3.15 that build failed.
Which one to use. For one .gitignore applied to a list of file paths where speed matters
most, pathspec with google-re2 or hyperscan installed is the fastest. For a real repository
tree with nested .gitignore files, results that must match git, a whitelist that keeps parent
directories, a copytree filter or a shell pipeline, use igittigitt.
Install
uv is the recommended installer.
# as a project dependency
uv add igittigitt
# as a standalone CLI tool (isolated environment, added to PATH)
uv tool install igittigitt
# run once without installing
uvx igittigitt --help
# or classic pip / pipx
pip install igittigitt
pipx install igittigitt
The project targets Python 3.10+ and is tested on Linux and Windows across CPython 3.10-3.15 and the free-threaded 3.14t and 3.15t builds, and on macOS with the newest of them. See INSTALL.md for every install method.
From Python 3.14 orjson is optional, since it has no free-threaded build: pip install "igittigitt[orjson]" adds it. Without it, --set values are read with the standard library,
which gives the same answers.
Why we recommend uv: supply-chain protection
This repository commits a uv.lock. It pins every package the project needs, transitive
dependencies included, to an exact version and to the hashes of that version's files. The
exclude-newer setting under [tool.uv] in pyproject.toml adds a cooldown: uv leaves any
release younger than that out of the lock. CI installs from the lock, so a hijacked release that
gets pulled again within the cooldown never reaches our builds, and a file whose hash does not
match is refused.
That protection stays in this repository. The installable package declares only lower bounds
(>=) for its dependencies, so a plain pip install takes the newest release of every transitive
dependency at the moment you run it. If one of them was hijacked an hour earlier, you get the
hijacked version. pipx install and uv tool install without options do the same.
To install the command line tool with a cooldown of your own (uv then skips any release younger than 7 days, transitive ones included), or to run the exact tree our CI tests:
uv tool install --exclude-newer "7 days" igittigitt
git clone https://github.com/bitranox/igittigitt.git && cd igittigitt && uv sync --locked && uv run igittigitt --help
If you depend on igittigitt in your own project, give that project the same cooldown (7 days here, as
an example) and commit the uv.lock that uv add igittigitt writes:
[tool.uv]
exclude-newer = "7 days"
Library usage
Ignore mode
import igittigitt
parser = igittigitt.IgnoreParser()
# discover and parse every .gitignore below base_dir (per-directory precedence)
parser.parse_rule_files(base_dir="/opt/project")
# ... or add rules explicitly
parser.add_rule("*.py[cod]", base_path="/opt/project")
parser.add_rule("!keep.pyc", base_path="/opt/project")
parser.match("/opt/project/main.pyc") # True (ignored)
parser.match("/opt/project/keep.pyc") # False (re-included by the negation)
ignored, rule = parser.match_with_rule("/opt/project/main.pyc")
rule.pattern_original # '*.py[cod]' - the deciding rule, also returned for a negation
match_with_rule returns (ignored, rule); the rule (or None when nothing matched) carries
pattern_original, is_negation_rule, source_file and source_line_number (both None for a
rule added with add_rule).
Rules ending in / (build/) match directories only, so match needs to know whether a path is
one. It decides as git does: a directory when the path is a string ending in / or is a directory
on disk; anything else is a file, including a path that does not exist and a symlink to a
directory. A pathlib.Path drops a trailing slash, so pass is_dir=True for a directory that is
not on disk. When you already know the type (a find -type f stream, os.scandir entries), pass
is_dir= and no system call is made:
parser.match("/opt/project/build/") # a directory, written with the slash
parser.match("/opt/project/build", is_dir=True) # the same, said explicitly
parser.match("/opt/project/build/out.o", is_dir=False) # a file, no stat
parse_rule_files also loads git's user-level ignore file ($XDG_CONFIG_HOME/git/ignore, or
~/.config/git/ignore), as git does: pass add_default_patterns=False to skip it, set
igittigitt.conf_igittigitt.add_default_patterns = False to change that default for later calls, or
call load_default_patterns(base_dir) to add it to a parser on its own. IgnoreParser(dir_cache_max=N)
sets the directory-decision cache for one parser (see [performance] below).
Use it as a shutil.copytree filter to copy a tree without the ignored files:
import shutil, igittigitt
parser = igittigitt.IgnoreParser()
parser.parse_rule_files(base_dir="src_tree")
shutil.copytree("src_tree", "dst_tree", ignore=parser.shutil_ignore)
Spaces, backslashes and comments in rule lines
A rule line is read exactly as git reads it. Git cuts only the final run of unescaped spaces;
a backslash escapes the character after it, so \ keeps a space and \\ is a literal
backslash. Tabs are never cut, and nothing is cut at the start of a line: leading spaces are part
of the pattern, and only a # in the first column starts a comment, so an indented !keep.log
is a pattern for a file of that name, not a negation. A blank or spaces-only line, and a line
ending in a backslash that escapes nothing (lone\), match no path. pattern_original and
check -v show the line with its trailing spaces cut, as git check-ignore -v does.
import igittigitt
parser = igittigitt.IgnoreParser()
for line in [
"*.log ", # trailing spaces are cut: the rule is "*.log"
r"name\ ", # an escaped space stays: matches "name "
r"two \ ", # the plain space before it stays too: matches "two "
r"pair \\\\ ", # "pair", a space, 2 escaped backslashes; the last space is cut
"tab\t", # a tab is never cut: matches "tab<TAB>", not "tab"
" indented", # leading spaces belong to the pattern
" # not a comment", # only a '#' in the first column starts a comment
"# a comment",
r"\#hash", # escape a leading '#' to match a name that starts with one
" !keep.log", # not a negation: a pattern for the name " !keep.log"
"lone\\", # ends in one unpaired backslash: matches nothing
]:
parser.add_rule(line, base_path="/opt/project")
parser.match("/opt/project/app.log") # True
parser.match("/opt/project/name ") # True
parser.match("/opt/project/name") # False
parser.match("/opt/project/two ") # True (two spaces)
parser.match("/opt/project/two ") # False
parser.match(r"/opt/project/pair \\") # True (two backslashes)
parser.match("/opt/project/tab\t") # True
parser.match("/opt/project/tab") # False
parser.match("/opt/project/ indented") # True
parser.match("/opt/project/indented") # False
parser.match("/opt/project/ # not a comment") # True
parser.match("/opt/project/#hash") # True
parser.match("/opt/project/keep.log") # True (still ignored by *.log)
parser.match("/opt/project/lone") # False
The same rules apply to every rule file the parser reads and to the CLI's --rule (-r)
values. add_rule takes one line without its line ending and removes nothing beyond git's own
cut of trailing spaces, so never .strip() a line before passing it, but do drop the whole line
ending you read with it (\r\n or \n) and a byte order mark on the first line: a \r or BOM
left on the line becomes part of the pattern. To load a rule file, call parse_rule_file instead
of reading it yourself; like git, it ends a line only at \n, drops one \r before it, and skips
a leading UTF-8 byte order mark. The names in this example are POSIX file names; Windows does not
allow a trailing space, a tab or a backslash in a file name.
Whitelist / include mode
IncludeParser keeps only what matches; everything else is dropped. Including a
directory keeps its whole subtree, and unanchored patterns are found at any depth:
import shutil, igittigitt
inc = igittigitt.IncludeParser()
inc.add_rule("*.py", base_path="src_tree") # keep only python files...
inc.add_rule("docs/", base_path="src_tree") # ...and the whole docs/ subtree
# copy only the kept files (parent directories are descended into automatically)
shutil.copytree("src_tree", "dst_tree", ignore=inc.shutil_include)
inc.match("src_tree/pkg/deep.py") # True (kept)
IncludeParser reads rule files the same way (parse_rule_file, parse_rule_files) and takes the
same dir_cache_max argument.
CLI usage
# which of these paths are ignored? (like `git check-ignore`)
igittigitt check -C /path/to/repo a.log src/main.py
# exit 0 if at least one path is ignored, 1 if none
# show the deciding rule (source:line:pattern), like `git check-ignore -v`: as in git, a
# path a negation re-includes is listed too and that makes the exit 0 (without -v it is
# not ignored: exit 1); the rule file is named relative to -C
igittigitt check -C /path/to/repo -v a.log
# Unix filter: drop ignored paths from a stream
find . -type f | igittigitt filter
# keep only what matches the include patterns
find . -type f | igittigitt filter --include -r '*.py'
# paths can also be given as arguments
igittigitt filter -C /path/to/repo a.log src/main.py
# a path ending in / is taken as a directory, as in git: with rule build/, `build/` is
# ignored even when no build directory exists, and a missing `build` is not
igittigitt check -C /path/to/repo build/
# NUL-separated I/O for paths with spaces/newlines
find . -print0 | igittigitt filter -z | xargs -0 ...
# inline rules and explicit ignore files
igittigitt check -r '*.tmp' -f .gitignore --stdin < paths.txt
Global options
| Option | Description |
|---|---|
--version |
Print the version and exit. |
--traceback / --no-traceback |
Show a full Python traceback on errors (default: off). |
--profile NAME |
Load configuration from a named profile. |
--set SECTION.KEY=VALUE |
Override one config value (repeatable), e.g. --set performance.dir_cache_max=16384. |
--env-file PATH |
Use an explicit .env file (skips the upward search). |
-h, --help |
Show help. |
Commands
| Command | What it does |
|---|---|
info |
Print resolved package metadata. |
check [PATHS...] |
Print the paths that are ignored (mirrors git check-ignore, -v included). Reads stdin with --stdin, -, or when no path is given. Exit 0 if any matched, 1 if none. |
filter [PATHS...] |
Unix filter: read paths from stdin (or the arguments) and print the survivors. --include switches to whitelist mode. Exit 0. |
config |
Print the merged, layered configuration (with provenance). |
config-deploy |
Write the default config files into the app/host/user config directories. |
config-generate-examples |
Write example config files you can copy and edit. |
logdemo |
Emit sample log records; --theme classic|dark|neon|pastel previews a console theme. |
Shared check / filter options: -C/--base-dir, -f/--gitignore FILE (repeatable),
-r/--rule PATTERN (repeatable), --scan/--no-scan, --default-patterns, -z/--zero
(NUL I/O), check only: -v/--verbose and --stdin, filter only: -i/--include.
Two defaults differ from what you might expect:
--default-patternsis off on the command line, whileparse_rule_filesloads git's user-level ignore file by default.git check-ignorereads that file too, so pass--default-patternswhencheckmust answer exactly as git does on your machine.--includekeeps only what the-r/-frules match; it never scans for.gitignorefiles, so with neither option it prints nothing.--scanand--default-patternsapply to ignore mode.
With -v -z, check writes each record as four NUL-terminated fields
(source, line, pattern, path), as git check-ignore -v -z does.
check and filter stream their input and write results immediately, with clean
SIGPIPE handling - so ... | igittigitt filter | head works without a traceback; the
command then exits 141.
Configuration
igittigitt uses lib_layered_config: settings are merged from, lowest to highest precedence,
bundled defaults -> app -> host -> user -> .env file -> environment variables -> --set
Inspect the effective configuration with igittigitt config, and deploy editable copies
with igittigitt config-deploy. Override a single value per run with --set, in a .env
file as SECTION__KEY=value, or via an environment variable as IGITTIGITT___SECTION__KEY=value.
When a configuration file cannot be loaded, config, check and filter exit 78 with one line
naming it, while info, config-deploy (which replaces the file), config-generate-examples,
logdemo and --help still run; a malformed --set or an invalid --profile name exits 2. See CONFIG.md.
[performance] - engine and CLI tuning
These knobs only affect speed and cache memory, never which paths match. Defaults were chosen by measurement; all keep memory bounded.
| Key | Default | Meaning |
|---|---|---|
dir_cache_max |
8192 |
Capacity of the per-parser directory-decision LRU cache (0 disables it). The main speed-up on tree-shaped workloads; memory is O(this), not O(#files). |
pattern_cache_max |
4096 |
Capacity of the process-wide compiled-regex cache (keyed by distinct pattern). |
stdin_chunk_bytes |
65536 |
Read granularity for streaming paths from stdin. |
max_token_bytes |
1048576 |
Per-path safety bound; a separator-less token larger than this is rejected instead of buffered unbounded. |
Example: igittigitt --set performance.dir_cache_max=32768 filter -C repo.
[lib_log_rich] - logging
Logging is provided by lib_log_rich. The
[lib_log_rich] section configures console level/theme, journald/eventlog/Graylog
backends, queueing, scrubbing and payload limits. Every key is documented inline in the
deployed config.d/90-logging.toml; for example set the console level with
igittigitt --set lib_log_rich.console_level=DEBUG info or
IGITTIGITT___LIB_LOG_RICH__CONSOLE_LEVEL=DEBUG.
The full, commented settings live in the bundled config files (see config-generate-examples)
and in CONFIG.md.
Claude Code skill
This repo is itself a Claude Code
plugin/marketplace and ships a skill (skills/python-gitignore/)
that teaches Claude how to install, configure and use igittigitt (library, CLI, and bash
piping). Install it in any project:
/plugin marketplace add bitranox/igittigitt
/plugin install igittigitt
The same skill is also mirrored in the central bitranox marketplace
(https://github.com/bitranox/bitranox-skills) as coding-python-gitignore.
AI transparency
This project was built by a human with AI assistance, used as a tool under human direction.
- ai-stance.md - why we work this way and how we think about AI in software.
- ai-disclosure.md - exactly where AI was and was not used in this project, and what has and has not been tested.
Naming
igittigitt is German: the doubled igitt, what German speakers, and children above all, cry out when something disgusts them, much like "yuck!" in English. It suits the files you would rather git never saw.
Further Documentation
- INSTALL.md - every installation method.
- DEVELOPMENT.md - make targets, testing, release workflow.
- CHANGELOG.md - release history.
- CONTRIBUTING.md - how to contribute.
Metadata
Release files for igittigitt 2.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| igittigitt-2.7.1.tar.gz | 153.5 kB | With provenance | Details for igittigitt-2.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| igittigitt-2.7.1-py3-none-any.whl | Python 3 | none | any | Details for igittigitt-2.7.1-py3-none-any.whl |
Total release size: 250.0 kB
Release files / igittigitt-2.7.1.tar.gz
| Download URL | igittigitt-2.7.1.tar.gz |
|---|---|
| Size | 153.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75fc3b879ce101264ed446a44739c939d43b0631e3157892b03e592a83db6be8
|
|
BLAKE2b-256 checksum How to use checksums |
90b6e335eaf2b42df520b26aab426b9030bc7857d97df3c2b5433352d75e1653
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / igittigitt-2.7.1-py3-none-any.whl
| Download URL | igittigitt-2.7.1-py3-none-any.whl |
|---|---|
| Size | 96.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef97e18cdbbcf39ca849e5d5a1222a3a8aeda0269e1c1510878a9a5e26d808e5
|
|
BLAKE2b-256 checksum How to use checksums |
71559325b4bc67ae1fc1d557ab510541a5f0ddc69130b6290527cfd0f0e74c4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for igittigitt 2.7.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for igittigitt-2.7.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.