Skip to main content

git-check-ignore

This is a wrapper around git's check-ignore command.

It can be used to determine if a particular pathname would be ignored by a repository's .gitignore files. It shells out to git to accomplish this. This has the disadvantage that you must have git installed and available on your PATH, but has the advantage that this module's results will always agree with git's.

Test, build, and publish

Installation

git-check-ignore can be installed from PyPI:

pip install git-check-ignore

Documentation

Documentation can be found at https://dd-dockyard.github.io/git-check-ignore/

The source code can be found at https://github.com/dd-dockyard/git-check-ignore

Example Usage

The ignored_pathnames and not_ignored_pathnames functions are the simplest way to use this module. Given a list of names, they iterate through the names that would or would not be ignored by git:

from git_check_ignore import ignored_pathnames, not_ignored_pathnames

for ignored in ignored_pathnames("README.md", "foo.py", "bar.py"):
    print(f"{ignored} is ignored")

for not_ignored in not_ignored_pathnames("README.md", "foo.py", "bar.py"):
    print(f"{not_ignored} is not ignored")

The ignored_paths and not_ignored_paths functions are the same, but return pathlib.Path objects:

from git_check_ignore import ignored_pathnames, not_ignored_pathnames

for ignored in ignored_paths("README.md", "foo.py", "bar.py"):
    if ignored.exists():
        print(f"{ignored} is ignored and exists")

for not_ignored in not_ignored_paths("README.md", "foo.py", "bar.py"):
    if not_ignored.exists():
        print(f"{not_ignored} is not ignored and exists")

The git_check_ignore function provides the most information, and allows you to determine which .gitignore pattern matched a particular pathname:

from git_check_ignore import git_check_ignore

for r in git_check_ignore("README.md", "foo.py", "bar.py"):
    if r.ignored:
        print(f"{r.pathname} is ignored")
    if r.match:
        print(f"matched {r.match.pattern} at line {r.match.linenum} of {r.match.source}")

License

This software is provided under the terms of the AGPL 3.0 license.

Metadata

Release files for git-check-ignore 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-check-ignore 1.0.1
File Size Uploaded Provenance Actions
git_check_ignore-1.0.1.tar.gz 17.9 kB With provenance Details for git_check_ignore-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for git-check-ignore 1.0.1
File Interpreter ABI Platform Actions
git_check_ignore-1.0.1-py3-none-any.whl Python 3 none any Details for git_check_ignore-1.0.1-py3-none-any.whl

Total release size: 34.1 kB

Release files / git_check_ignore-1.0.1.tar.gz

Download URL git_check_ignore-1.0.1.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a0c6d6be218846a30aadf2bb0ffadebf06e53264278fc8f71366ee0620dae428
BLAKE2b-256 checksum
How to use checksums
cf23404ed51f46eeccf9af78448800d595124a0ae1e19a47ee0f08acd59a5675
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Apr 22, 2025.

Transparency log

Release files / git_check_ignore-1.0.1-py3-none-any.whl

Download URL git_check_ignore-1.0.1-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2835f87c04c836bb65eb227e8c439aa4bbbaee98b974d9e3d04ff3bb0093530
BLAKE2b-256 checksum
How to use checksums
7c54946a78f4a370676a2fda47676d25ea2770f73b7e34eb87bf32ba4bfbb2a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Apr 22, 2025.

Transparency log

Security for git-check-ignore 1.0.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for git_check_ignore-1.0.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 Apr 22, 2025.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page