GitPython

3.1.46 · active · verified Sat Mar 28

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.

Warnings

Install

Imports

Quickstart

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}')

view raw JSON →