Skip to main content

git-explain

Suggests conventional git add / git commit messages from your changes. Uses AI when you configure a key; otherwise uses simple local rules.

PyPI GitHub tag


Install and upgrade

pip install git-explain
pip install --upgrade git-explain

Use the second command anytime you want the latest release from PyPI.

In a terminal, go to your project folder (the one that contains .git) and run:

git-explain

The first time you run it without AI_MODEL set, the tool offers to create .env for your API key and shows a link to create one — it uses a built-in default Gemini model for that run but does not write a model into .env. Google renames and retires model ids over time, so nothing is pinned automatically; set AI_MODEL yourself (or pass --model) once you want a specific one to stick.


Configure (.env)

Put a file named .env in the repo root (next to .git). Typical variables:

Variable Role
AI_MODEL Gemini model id, e.g. gemini-2.5-flash. Optional — if unset, the tool uses its built-in default for that run without writing anything to .env.
AI_API_KEY From Google AI Studio.
AI_MODEL_FALLBACKS Optional: comma-separated backup models, tried in order after AI_MODEL when it's busy, overloaded, or not a valid model id. If you omit this variable, the tool uses the default fallbacks below.

You never have to get the model id exactly right: an unset, mistyped, or retired AI_MODEL all fall through to the same fallback chain as a busy/rate-limited model, so the tool keeps working even if Google renames or removes a model you had pinned.

Default AI_MODEL_FALLBACKS (when the variable is unset): gemini-2.5-flash-lite, then gemini-3-flash-preview — each is tried in sequence after a failed attempt on the previous model in the chain (starting from AI_MODEL).

If AI_API_KEY is empty, GEMINI_API_KEY is still read (same key, older name).


Flags

--auto Apply suggested commands without a confirmation prompt.
--staged-only Work with staged changes only (no git add from the tool).
--cwd Use another directory as the git repo root.
--model Override the AI model for this run (defaults to AI_MODEL from the repo .env).
--with-diff Send the full diff to the AI (more context).
--suggest Print one suggested git commit -m "…" line (staged, AI only).

If you pick more than one changed file, you can choose one commit or split into several (split is not available with --staged-only). Enter applies the suggestion; n skips so you can copy instead.

Commit messages follow Conventional Commits (feat:, fix:, optional scope, etc.).


When AI fails

Wrong key or network/quota errors that survive the whole fallback chain → the tool falls back to local heuristics and shows a warning. A busy/overloaded model or a bad/unknown model id steps through the fallback chain instead: your AI_MODEL (or the built-in default, if unset) first, then the models in AI_MODEL_FALLBACKS (or the default gemini-2.5-flash-lite → gemini-3-flash-preview list if that variable is unset).


Install a specific version from GitHub

pip install "git+https://github.com/nazarli-shabnam/git-explain.git@v2.3.0"
pip install "git+https://github.com/nazarli-shabnam/git-explain.git@v2.4.0"

Replace v2.3.0 with the tag you want.


Develop

From a clone of this repo:

pip install -r requirements.txt
python -m git_explain

Contributors: pip install -e ".[dev]" then pytest -q, ruff check ., ruff format --check ..

Metadata

Release files for git-explain 2.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-explain 2.6.0
File Size Uploaded
git_explain-2.6.0.tar.gz 38.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-explain 2.6.0
File Interpreter ABI Platform
git_explain-2.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 70.8 kB

Release files / git_explain-2.6.0.tar.gz

Download URL git_explain-2.6.0.tar.gz
Size 38.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0d1aed56ee98a4c98e1d650b615f96323beac400f1167222ce7b2737a6eaf121
BLAKE2b-256 checksum
How to use checksums
414605609404ef2cb6393c0e230a035814d67a0ffc58317b4d0f9fe8c8a70653
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release files / git_explain-2.6.0-py3-none-any.whl

Download URL git_explain-2.6.0-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4456743de6b09c03501f6dc647a3bb48274acc3fca820c5fc5d0cb7028a47dc0
BLAKE2b-256 checksum
How to use checksums
3c123a5b413b1f472fd36085ec3288ea85b4a3328f590447252407a30b20aadb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release history Release notifications | RSS feed

2.6.1

2 release files

This release

2.6.0 This release

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.9

2 release files

2.1.8

2 release files

2.1.7

2 release files

2.1.6

2 release files

2.1.5

2 release files

2.1.4

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page