skillfed

gitignorefile

A spec-compliant `.gitignore` parser for Python

gitignorefile v1.1.2 105.4K downloads/30d#12,703 on PyPI11
Permissive license MIT Abandoned released

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 gitignorefile

uv

uv add gitignorefile

poetry

poetry add gitignorefile

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Version Control :: GitTopic :: Text Processing :: Filters

Tags

gitignore parser pythoncheck if file matches gitignoreparse gitignore rulesgitignore pattern matchingignore file handlinggit ignore compliancedirectory tree ignore rules
git-toolingfile-filtering

More Python Modules packages