Skip to main content

gitignore_lib

This library (and simple CLI application) parses and applies rules from .gitignore files. It can be used to provide gitignore-like functionality to your applications with a familiar syntax and behavior.

Installation

It is available on PyPI: https://pypi.org/project/gitignore-lib/. So use the default Python ways:

pip install gitignore_lib

If you are interested in using the CLI tool (it is not very exciting, but who knows?), use pipx, uv or something similar:

pipx install gitignore_lib

Basic usage

Just open a .gitignore file and use the resulting object to match paths against the rules. For example:

from gitignore import load # it also offers loads(), dump() and dumps()

ignore = load(".gitignore", base="/path/to/repo")
ignore("some/path/to/file.txt") # True, if the file is ignored

The ignore object also provides methods for filesystem traversal. For instance, the walk() method behaves similarly to Path.walk() from pathlib:

for dirpath, dirnames, filenames  in ignore.walk("/path/to/repo"):
    for file in filenames:
        print(dirpath / file) # non-ignored files only!

If you want to learn more, check the documentation.

Metadata

Release files for gitignore-lib 0.1.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 gitignore-lib 0.1.1
File Size Uploaded
gitignore_lib-0.1.1.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gitignore-lib 0.1.1
File Interpreter ABI Platform
gitignore_lib-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.7 kB

Release files / gitignore_lib-0.1.1.tar.gz

Download URL gitignore_lib-0.1.1.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6ed9c1b6e45b989f9c6857064012f2463cf158f9d4e60c2cce5ac2f5f1ba3021
BLAKE2b-256 checksum
How to use checksums
2740bb91bc8af9eda702ec80b2b8824d6b2f6aaed73c944469ed46ff9b78dd58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gitignore_lib-0.1.1-py3-none-any.whl

Download URL gitignore_lib-0.1.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46bc645b92c6dba202cf0f2b1f39a2bd5f711e9d9c4af9e47a95eeeda53eb50b
BLAKE2b-256 checksum
How to use checksums
e63fd9c04e2ff37a0c02af5293ab303201231d1b00f5c48dbd224f2a31d6880b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

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