--- id: gitmatch version: "0.3.0" license: MIT license_treatment: permissive maintenance: active --- # gitmatch — Gitignore-style path matching License: permissive · Maintenance: active · Downloads: 87.7K/mo ## What it is and what it does Gitmatch is a pure Python library that brings gitignore pattern matching semantics to your code. You compile a list of gitignore-style patterns (including negations with `!` prefix) into a matcher object, then test relative file paths against it to determine if they match. The matcher returns a match object that tells you not just whether a path matched, but which pattern matched it and whether that pattern was a negation. The library handles the full gitignore syntax including wildcards, directory-only patterns (trailing `/`), and negation rules. It has no external dependencies and runs on Python 3.10+, making it straightforward to embed in tools that need to respect or replicate gitignore behavior without shelling out to git itself. Use it for: - Build tools that need to respect .gitignore rules when deciding which files to process or exclude. - File synchronization or backup utilities that filter paths using gitignore patterns. - Code generators or linters that should skip files matching project ignore rules. - Testing frameworks that need to exclude test files or directories based on gitignore patterns. - Static analysis tools that want to honor ignore patterns without invoking git. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Gitmatch implements gitignore-style pattern matching for file paths, letting you compile patterns and test whether relative paths match them. Yes. Gitmatch is a focused, well-maintained library with zero dependencies, permissive licensing, and active development. Install it if you need to match file paths against gitignore-style patterns in Python code without shelling out to git. The only constraint is Python 3.10+. ## Install pip install gitmatch uv add gitmatch poetry add gitmatch ## Installing gitmatch Before you install: Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 2026-07-20 with recent release activity. License in practice: MIT license permits unrestricted use, modification, and distribution in both open and closed projects. Quickstart: import gitmatch gi = gitmatch.compile(["foo", "!bar", "*.dir/"]) match_result = gi.match("foo/bar") if match_result: print(f"Matched pattern: {match_result.pattern}") Requires Python 3.10 or higher. Verify before relying: - Exact behavior differences from git's wildmatch implementation (e.g., edge cases in negation or directory matching). - Performance characteristics on large pattern sets or deeply nested paths. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 87.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags gitignore pattern matching, path matching with gitignore syntax, wildcard file path filtering, fnmatch glob patterns, gitignore-style path filtering, gitignore, pattern-matching [View on SkillFed](https://skillfed.io/packages/gitmatch) · [View on PyPI](https://pypi.org/project/gitmatch/)