gitignore-parser
A spec-compliant gitignore parser for Python 3.5+
What it is and what it does
gitignore_parser is a Python library that reads .gitignore files and produces a callable matcher function. You pass it a gitignore file path or a string of gitignore rules, and it returns a function that you can call with file paths to determine whether they match the ignore patterns. The library claims to support the full gitignore spec, including features like square-bracket character classes (e.g., `*.py[cod]`) and top-level path anchors (e.g., `/...`), which the author notes are missing from some competing libraries.
The package has no runtime dependencies and supports Python 3.5 through 3.12. It was first released in 2018 and has been maintained sporadically; the most recent release was 354 days ago. The repository remains active with recent commits, but the long release interval suggests the package may be in a stable-but-not-actively-developed state.
Use it for:
- Build tools and file processors that need to respect .gitignore rules when scanning project directories.
- Testing frameworks that want to exclude ignored files from test discovery or coverage reports.
- Version control utilities or scripts that programmatically check whether files should be tracked.
- Project analysis tools that need to filter out ignored paths when walking a directory tree.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses .gitignore files and returns a callable matcher that tests whether file paths should be ignored according to gitignore rules.
Yes, if you need to programmatically evaluate gitignore rules in Python. The package is stable, has no dependencies, supports a wide range of Python versions, and carries no known vulnerabilities. The long release interval and aging maintenance status are not blockers for a mature, single-purpose library, but you should verify that it handles your specific gitignore patterns correctly before relying on it in production.
Install
gitignore-parser on PyPI
pip
pip install gitignore-parseruv
uv add gitignore-parserpoetry
poetry add gitignore-parserInstalling gitignore-parser
Before you install
High install friction: the package has no runtime dependencies but has not been released in 354 days, and its status is marked as aging. The repository is not archived and has recent commits, but the long gap between releases may indicate limited active maintenance.
License in practice
MIT license (permissive) means you can use, modify, and distribute this package freely in both open-source and commercial projects with minimal restrictions.
Quickstart
from gitignore_parser import parse_gitignore
matches = parse_gitignore('/path/to/.gitignore')
if matches('/path/to/file.pyc'):
print('File is ignored')
Verify before relying
- Whether the package handles all edge cases of the gitignore spec (the description mentions it aims to be spec-compliant but does not detail which spec version or known limitations).
- Current test coverage and whether the aging maintenance status reflects active use or dormancy.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | aging — 354 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,988,275/month — #2,799 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: gitignore_parser-0.1.13.tar.gz
Keywords: gitignore
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
gitignorantParses .gitignore files and matches file paths…
permissive · top 15,000 on PyPI
gitignorefileParses `.gitignore` files according to Git's…
permissive · top 15,000 on PyPI
igittigittA spec-compliant .gitignore parser that matches…
permissive · top 15,000 on PyPI
py-walkFilters filesystem paths using gitignore-style…
permissive · top 5,000 on PyPI
pathspecMatches file paths against gitignore-style…
copyleft · top 100 on PyPI
gitmatchGitmatch implements gitignore-style pattern…
permissive · top 15,000 on PyPI
trailrunnerWalk filesystem paths while respecting…
permissive · top 5,000 on PyPI
rignoreProvides fast directory traversal with support…
permissive · top 1,000 on PyPI
ignoreDownloads and installs common .gitignore…
permissive · top 15,000 on PyPI
ignore-pythonProvides fast recursive directory traversal…
unclear · top 15,000 on PyPI