git-python by pynickle is a lightweight Python wrapper that simplifies a small subset of Git commands for personal use. It functions primarily as a command-line tool, providing simplified commands like `init`, `add`, and `commit`. It is not the widely-used `GitPython` library (note the capitalization). The current version is 1.1.2, with an irregular release cadence focused on personal utility.
Install & Compatibility
Where this runs
tested against v1.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.9MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.8s · import 0.000s · 20MB
18MB installed
● package 18MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from main import GitPython
This quickstart demonstrates how to interact with `git-python` using its command-line interface via `subprocess`, which is its primary intended mode of operation. It initializes a new Git repository, creates a file, adds it, and commits it within a temporary directory.
import subprocess
import os
import tempfile
import shutil
# Create a temporary directory for the Git repo
temp_dir = tempfile.mkdtemp()
print(f"Created temporary directory: {temp_dir}")
original_cwd = os.getcwd()
try:
os.chdir(temp_dir)
# 1. Initialize a new gitpython repository
print("Initializing gitpython repository...")
result = subprocess.run(["gitpython", "gp", "init"], capture_output=True, text=True, check=True)
print(f"init stdout:\n{result.stdout}")
# 2. Create a file
with open("example.txt", "w") as f:
f.write("Hello, git-python!")
print("Created example.txt")
# 3. Add the file
print("Adding example.txt...")
result = subprocess.run(["gitpython", "gp", "add", "."], capture_output=True, text=True, check=True)
print(f"add stdout:\n{result.stdout}")
# 4. Commit the file
print("Committing changes...")
result = subprocess.run(["gitpython", "gp", "commit", "-m", "Initial commit via git-python CLI"], capture_output=True, text=True, check=True)
print(f"commit stdout:\n{result.stdout}")
# Verify using standard git CLI (optional, but good for demo)
print("\nVerifying with standard 'git' command:")
result = subprocess.run(["git", "log", "--oneline"], capture_output=True, text=True, check=True)
print(f"git log stdout:\n{result.stdout}")
except subprocess.CalledProcessError as e:
print(f"Error during subprocess call: {e}")
print(f"Stdout: {e.stdout}")
print(f"Stderr: {e.stderr}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
finally:
os.chdir(original_cwd)
# Clean up the temporary directory
print(f"Cleaning up temporary directory: {temp_dir}")
shutil.rmtree(temp_dir)
git-python --version
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.