Registry / devops / git-python

git-python

JSON →
library1.1.2pypypi✓ verified 33d ago

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.

devops
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
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.9MB
glibc
py 3.103.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
from main import Repo

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
Debug
Known footguns
gotchaThere is a significant naming collision: `git-python` (this library, by pynickle) vs. `GitPython` (a comprehensive and widely-used library for programmatic Git interaction by gitpython-developers). They are distinct projects with different APIs and functionalities.
gotchaThis `git-python` library is primarily designed as a command-line tool, not for direct programmatic imports. Its internal `GitPython` class methods (e.g., `init`, `add`) often rely on the script's execution environment or `os.path.dirname(__file__)` to determine paths, making them unsuitable for managing arbitrary Git repositories programmatically from a different script context.
gotchaThe `git-python` library (pynickle) provides a very limited subset of Git commands, including only `init`, `add`, and `commit`. It is not intended as a full-featured Git client or wrapper.
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
9 hits · last 30 days
gptbot
4
ahrefsbot
3
script
1
Resources