Registry / devops / gitpython

gitpython

JSON →
library3.1.46pypypi✓ verified 35d ago

GitPython is a Python library used to interact with Git repositories. The current version is 3.1.46, released on March 28, 2026. It follows a regular release cadence, with updates addressing bug fixes, feature enhancements, and security patches.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Ensure 'git' is the correct package name; 'gitpython' is the package name, but the import uses 'git'.

from git import Repo

This script demonstrates how to initialize a Git repository and access the latest commit message using GitPython. Replace '/path/to/your/repo' with the actual path to your Git repository.

import os from git import Repo # Set the repository path repo_path = os.environ.get('REPO_PATH', '/path/to/your/repo') # Initialize the repository repo = Repo(repo_path) # Access the latest commit commit = repo.head.commit # Print the commit message print(f'Latest commit: {commit.message}')
git --version
Debug
Known footguns
breakingGitPython requires Python 3.7 or higher. Attempting to use it with an older version will result in an ImportError.
gotchaEnsure that both 'gitdb' and 'smmap' are installed, as they are dependencies for GitPython. Missing these can lead to ImportError.
breakingGitPython requires the 'git' command-line tool to be installed and accessible in the system's PATH, or its path explicitly configured. Missing 'git' will result in an ImportError.
breakingGitPython requires the 'git' command-line tool to be installed on the system and accessible in the system's PATH, or explicitly configured. Failure to do so will result in an ImportError: Bad git executable.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources