Python-Git
Automate the boring git stuff with python
Motivation
Whenever I wanted to see the status of all my git repos I have to fire up the
git-cmd.exe shell on windows, navigate to each folder and then do a git status.
I have to do this both at home and at work.
But I got quickly tired of it. So I decided to make this tool to give me a quick report so I can see what is ahead and what's behind and what's ahead at a glance. In short, what needs attention so as to avoid those troubling merge conflicts.
Requirements
Other thing you need is a computer with git either accessible from the command line (which means its in your system path) or as a standalone file somewhere in your system.
If you're working without installation rights, you can use a portable git and python-git will work just fine.
You can get a portable git version from here
Just unzip it and place it somewhere on your disk. Later (during initialization), you'll need to tell python-git where this file is located.
Installation
pip install python-git
Development setup (uv)
This project uses uv to manage the virtual environment and dependencies.
Install uv (macOS: brew install uv, other platforms: see the uv docs), then from the project directory:
uv sync
This creates .venv/, installs the package in editable mode and installs the dev tools (pytest, pylint, twine) pinned in uv.lock.
Run things inside the environment with uv run:
uv run python -m pygit --help
uv run pytest
Add or remove dependencies with uv add <package> / uv remove <package>, and use uv add --dev <package> for dev-only tools. Alternatively, activate the environment with source .venv/bin/activate (Windows: .venv\Scripts\activate).
Setup
After installation, an initial setup is required to tell pygit the folders it needs to work with. Open a terminal and python -m pygit the below line with appropriate command line arguments.
The output of python -m pygit --help is shown below.
usage: Pygit. Initialize working directories for python-git
[-h] [-v {0,1}] [-r RULES [RULES ...]] [-g GITPATH]
[-m MASTERDIRECTORY] [-s SIMPLEDIRECTORY [SIMPLEDIRECTORY ...]]
optional arguments:
-h, --help show this help message and exit
-v {0,1}, --verbosity {0,1}
turn verbosity ON/OFF
-r RULES [RULES ...], --rules RULES [RULES ...]
Set a list of string patterns for folders to skip
during setup
-g GITPATH, --gitPath GITPATH
Full pathname to git executable. cmd or bash.
-m MASTERDIRECTORY, --masterDirectory MASTERDIRECTORY
Full pathname to directory holding any number of git
repos.
-s SIMPLEDIRECTORY [SIMPLEDIRECTORY ...], --simpleDirectory SIMPLEDIRECTORY [SIMPLEDIRECTORY ...]
A list of full pathnames to any number of individual
git repos.
As an example you I have a folder in my D: drive that holds all my git repos, so I will setup pygit with the following command
python -m pygit --m D:\git -v 1
If it happens that you clone more repos into your master directory, you may update the index by issuing the update()command inside a python shell.
pygit.update()
Usage
Activate python environment on command line.
import pygit
In case things change (perhaps you moved folders around or you add a new git repo) and you want to reset your folders just redo the initialization step
pygit.repos()
show all git repos in the format shown immediately below
pygit.load(repo_id_or_name) # load a repo
where repo_id is a string-valued id assigned to that particular repo. The first value in the repos command's output.
The load(input_string) command returns a Commands object for that repo, which provides a gateway for issuing git commands on the repository
Operations that can be performed on Commands object are shown below.
r = pygit.load_repo(repo_id_or_name)
r.fetch() # perform fetch
r.status() # see status
r.add_all() # stage all changes for commit
r.commit(message='chore: minor changes') # commit changes. Press enter to accept default message
r.push() # perform push action
r.pull() # perform pull request
r.add_commit() # add and commit at once
Batch Operations
The following batch operations on indexed repos are available.
pygit.load_multiple(*args) # load a set of repos
pygit.load_multiple("2", "5") # load only repo 2 and 5
returns a generator of Commands objects for repositories 2 and 5. Afterwards you can iterate over the repos like below
for each in pygit.load_multiple("2", "5"):
each.add_commit()
pygit.all_status()
performs a status command on all indexed repos. The result is written to a markdown file.
Carries a timestamp of the time the command was issued. Call it a snapshot of your repo status if you will. Items which are out of sync with their remote counterpart are also highlighted as needing attention.
pygit.pull_all()
perform a pull request on all indexed repos at once. It returns None.
pygit.push_all()
performs a push action on all indexed repos at once. It returns None.
pygit.load_all()
returns a generator of Commands object for each indexed repo.
To do
- Add
git-bash.exe - Implement
Commands.branch() - Refactor tests
- Auto-run test after importation to make sure every other thing works fine.
Metadata
Release files for python-git 2026.11.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_git-2026.11.15.tar.gz | 16.2 kB | Without provenance | Details for python_git-2026.11.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_git-2026.11.15-py3-none-any.whl | Python 3 | none | any | Details for python_git-2026.11.15-py3-none-any.whl |
Total release size: 30.9 kB
Release files / python_git-2026.11.15.tar.gz
| Download URL | python_git-2026.11.15.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fb65ebf63b05fdb63e3942f00929387e8a3daae6a234879689fca062f6790d4
|
|
BLAKE2b-256 checksum How to use checksums |
21c46f3829f70d013a2af19fd2e044f30e2d20e272e3cf6b121bc55c3a42decf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_git-2026.11.15-py3-none-any.whl
| Download URL | python_git-2026.11.15-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14e362860f91ee694ff31022ce1dd99d95c3b99f0b6c97b69f0be3716dd91b04
|
|
BLAKE2b-256 checksum How to use checksums |
7ce1ac379e6163ac6eeba8ca8078f04a47e9103dd572048c2ab4ae264d940195
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for python-git 2026.11.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.