--- id: pygit2 version: "1.20.0" license: GPLv2 with linking exception license_treatment: copyleft maintenance: active --- # pygit2 — Python bindings for libgit2. License: copyleft · Maintenance: active · Downloads: 5.6M/mo ## What it is and what it does pygit2 is a Python wrapper around libgit2, a C library that implements Git's core functionality. It lets you read and manipulate Git repositories programmatically—creating commits, managing branches, querying history, and performing other Git operations—without spawning git command-line processes. This is useful when you need fine-grained control over Git operations or want to embed Git functionality directly into a Python application. The package depends on cffi to interface with the compiled libgit2 library. Installation uses prebuilt wheels for common platforms (macOS, Linux, Windows) and Python versions (3.11–3.14, PyPy3 7.3+), reducing build complexity. The repository is actively maintained, with recent releases and ongoing development. Use it for: - Build Git-aware development tools or CI/CD systems that need to query or manipulate repositories programmatically. - Implement custom Git workflows or automation that would be cumbersome via shell commands. - Analyze repository history, metadata, or structure without spawning external processes. - Embed version control operations into Python applications that manage code or configuration. - Create Git hooks or server-side repository management logic in pure Python. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. pygit2 provides Python bindings to libgit2, enabling direct programmatic access to Git repository operations at the plumbing level without shelling out to the git command-line tool. Yes, if you need programmatic Git access in Python. pygit2 is actively maintained, well-supported across modern Python versions and platforms, has no known vulnerabilities, and carries a permissive copyleft license (GPLv2 with linking exception). Medium install friction is manageable via prebuilt wheels. Not necessary if you only need to shell out to git commands or if GitPython's higher-level API better fits your use case. ## Install pip install pygit2 uv add pygit2 poetry add pygit2 ## Installing pygit2 Before you install: Medium install friction due to compiled C extensions (cffi dependency); prebuilt wheels available for Python 3.11–3.14 on macOS, Linux, Windows, and PyPy3 7.3+. Repository is actively maintained with a release 6 days old and recent commits. License in practice: Licensed under GPLv2 with linking exception, a copyleft license. The linking exception permits combining the compiled library with other programs without imposing GPL terms on those programs, but modifications to pygit2 itself must remain under GPLv2. Quickstart: pip install pygit2 import pygit2 repo = pygit2.Repository('/path/to/repo') commit = repo.head.target Requires libgit2 system library; prebuilt wheels handle this on most platforms, but custom builds may need libgit2 development headers installed. Verify before relying: - Whether prebuilt wheels include all optional libgit2 features (SSH, HTTPS backends) or if some require system libraries. - Performance characteristics compared to GitPython or other Git bindings for large repositories. ## Package facts - License: GPLv2 with linking exception (copyleft) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 5.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags git repository access python, libgit2 python bindings, git plumbing operations, programmatic git manipulation, git version control library, python git api, git-bindings, version-control, libgit2 [View on SkillFed](https://skillfed.io/packages/pygit2) · [View on PyPI](https://pypi.org/project/pygit2/)