Cross-platform Git history access implemented in Rust with a Python API via PyO3 and libgit2.
Highlights
- Fast Git history access via libgit2 with a lightweight Python wrapper.
- Repo helpers for HEAD info, revision parsing, commit listing, and branch/tag lookup.
- History rewriting tools: amend messages, rewrite author/committer, reword arbitrary commits, squash, rebase (pick-only), drop commits, and purge paths.
- All rewrites return a
RewriteResultwith mappings and ref updates.
Install
pip install pygitx
Python usage
import pygitx
from pathlib import Path
repo = pygitx.open_repo(Path("."))
head = repo.head()
print("HEAD:", head.id if head else "None")
# Resolve a revision (branch/tag/oid) to a hex id
print("main ->", repo.rev_parse("main"))
for c in repo.list_commits(max=5):
print(f"{c.id[:7]} {c.author} <{c.email}> {c.summary}")
# Quick repo summary (also printed by str(repo))
print(repo.summary())
# Graph helpers
print("Branches:", repo.list_branches(local=True, remote=False))
print("Tags:", repo.list_tags())
print("Current branch:", repo.current_branch())
print("Merge base of main and feature:", repo.merge_base("main", "feature"))
print("Ahead/behind main vs feature:", repo.ahead_behind("main", "feature"))
print("Diff HEAD~1..HEAD:", repo.diff_stat("HEAD~1", "HEAD").files_changed, "files")
Example script: examples/demo.py (run with --help to see options).
Documentation
Full API and usage docs live in docs/ (Sphinx). Build locally with:
make docs
Or browse the published docs if available in your environment.
Development
- Run Rust and Python checks:
make test - Pytest for Python wrappers:
pytest - Make targets:
make venv,make install,make develop,make release,make docs,make test - Optional pre-commit prompt: set
git config core.hooksPath .githooksandchmod +x .githooks/pre-committo be prompted to runmake develop,make test, andpytestbefore each commit.
Metadata
Release files for pygitx 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pygitx-0.2.2-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for pygitx-0.2.2-cp39-abi3-win_amd64.whl |
| pygitx-0.2.2-cp39-abi3-manylinux_2_34_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.34+ x86-64 | Details for pygitx-0.2.2-cp39-abi3-manylinux_2_34_x86_64.whl |
| pygitx-0.2.2-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for pygitx-0.2.2-cp39-abi3-macosx_11_0_arm64.whl |
Total release size: 4.1 MB
Release files / pygitx-0.2.2-cp39-abi3-win_amd64.whl
| Download URL | pygitx-0.2.2-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
fc6776d0fdb14d47a8e089be79c5d69a5ab73df54876c214d6b0187c5b4412ec
|
|
BLAKE2b-256 checksum How to use checksums |
9aec169c9aaed5ba700914008da757a79fa1d2911485eb503f3fc0b35855f9a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Jan 7, 2026.
Transparency logRelease files / pygitx-0.2.2-cp39-abi3-manylinux_2_34_x86_64.whl
| Download URL | pygitx-0.2.2-cp39-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.9 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a58a312467a5c2ed9f94843a87e70dd3c244e7f66df042c87f77b2b37610dd3b
|
|
BLAKE2b-256 checksum How to use checksums |
93dd7e631b021362752473fcdbea268a8a764866f85722bf307829cd5fcb45b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Jan 7, 2026.
Transparency logRelease files / pygitx-0.2.2-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | pygitx-0.2.2-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
23b572b182bb20d310d504ebd5b058096c3467c87c1afde9d9a2c95d55cd90a9
|
|
BLAKE2b-256 checksum How to use checksums |
32a3d50ad45a01f0394499bee0c5d4077f3f8d4fa608cb87ebeac0b90b96860e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Jan 7, 2026.
Transparency logSecurity for pygitx 0.2.2
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 3 files in this release have been uploaded with provenance metadata.
Attestation for pygitx-0.2.2-cp39-abi3-win_amd64.whl
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 Jan 7, 2026.
Transparency logA 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.