gitignorefile
A spec-compliant `.gitignore` parser for Python
What it is and what it does
gitignorefile is a Python library that reads and interprets `.gitignore` files according to Git's specification. It provides functions to check whether individual file paths match ignore rules, either by parsing a single `.gitignore` file or by walking a directory tree to discover and apply all `.gitignore` and `.git/info/exclude` files in the hierarchy. The library also integrates with `shutil.copytree()` as an ignore callback and offers a caching layer to avoid re-parsing rules for repeated checks.
The package has no external runtime dependencies and supports Python 3.6 through 3.12. However, it is marked as abandoned—the last commit was in May 2023 and no releases have occurred since September 2022, so it will not receive updates for new Git features or bug fixes.
Use it for:
- Filter files during directory copy operations to respect .gitignore rules without invoking git itself
- Build tools or scripts that need to skip ignored files when scanning a project directory
- Implement custom file-processing pipelines that must honor gitignore semantics
- Test whether a file path would be ignored by Git without running git commands
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses `.gitignore` files according to Git's specification and checks whether file paths match the ignore rules, with support for caching and custom ignore file sources.
Yes, if you need lightweight gitignore parsing with no external dependencies and your use case does not require ongoing maintenance or support for new Git features. The library is stable and works on modern Python versions, but its abandoned status means no fixes or updates will be released. Suitable for stable, self-contained projects; avoid if you need active maintenance or expect gitignore spec changes to affect your workflow.
Install
gitignorefile on PyPI
pip
pip install gitignorefileuv
uv add gitignorefilepoetry
poetry add gitignorefileInstalling gitignorefile
Before you install
High install friction with no runtime dependencies. Package is marked abandoned (last commit 2023-05-29, 1440 days since release), though it carries a Production/Stable classifier and remains available for Python 3.6–3.12.
License in practice
MIT license is permissive; you may use, modify, and distribute this package freely with minimal restrictions.
Quickstart
import gitignorefile
matches = gitignorefile.parse("/path/to/.gitignore")
matches("/path/to/file.pyc") # Returns True or False
# Or check files against directory tree:
if gitignorefile.ignored("/path/to/file.py"):
print("File is ignored")
Verify before relying
- Whether the package correctly handles all edge cases in the gitignore spec (e.g., negation patterns, directory-only rules, trailing slashes)
- Performance characteristics when caching large directory trees with many .gitignore files
- Compatibility with recent Git versions' gitignore behavior changes since the last release in 2022
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 1,440 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 105,375/month — #12,703 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: gitignorefile-1.1.2.tar.gz
Keywords: git, gitignore
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
gitignorantParses .gitignore files and matches file paths…
permissive · top 15,000 on PyPI
gitignore-parserParses .gitignore files and returns a callable…
permissive · top 5,000 on PyPI
igittigittA spec-compliant .gitignore parser that matches…
permissive · top 15,000 on PyPI
ignoreDownloads and installs common .gitignore…
permissive · top 15,000 on PyPI
pathspecMatches file paths against gitignore-style…
copyleft · top 100 on PyPI
py-walkFilters filesystem paths using gitignore-style…
permissive · top 5,000 on PyPI
rignoreProvides fast directory traversal with support…
permissive · top 1,000 on PyPI
diff-parserParses git diff and .diff files to extract…
permissive · top 15,000 on PyPI
ripgrepProvides a Python interface to ripgrep (rg), a…
permissive · top 15,000 on PyPI
trailrunnerWalk filesystem paths while respecting…
permissive · top 5,000 on PyPI