CLI that suggests git add/commit from diffs using Gemini
Project description
git-explain
Suggests conventional git add / git commit messages from your changes. Uses AI when you configure a key; otherwise uses simple local rules.
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 in .env, the tool can create .env with a default Gemini model and a link to create an API key.
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. Set on first run if missing. |
AI_API_KEY |
From Google AI Studio. |
AI_MODEL_FALLBACKS |
Optional: comma-separated backup models, tried in order after AI_MODEL on retryable busy/rate-limit errors. If you omit this variable, the tool uses the default fallbacks below. |
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. |
--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, bad model name, network issues, or quota errors → the tool falls back to local heuristics and shows a warning. On retryable busy/rate-limit errors it steps through the fallback chain: your AI_MODEL 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 ..
GitAds Sponsored
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git_explain-2.4.0.tar.gz.
File metadata
- Download URL: git_explain-2.4.0.tar.gz
- Upload date:
- Size: 35.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddf73d2da481d690bb753cdd2e8db71988d53f14e8aef50c5ab17c0acbfaacaa
|
|
| MD5 |
a7ab8bf02cd3cadc84c539e63ec28776
|
|
| BLAKE2b-256 |
8b6f597c6b2e67a0a699d5b7e7d55e8f7a724a2d9cddae1784547b41b48494b5
|
Provenance
The following attestation bundles were made for git_explain-2.4.0.tar.gz:
Publisher:
pypi-publish.yml on nazarli-shabnam/git-explain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_explain-2.4.0.tar.gz -
Subject digest:
ddf73d2da481d690bb753cdd2e8db71988d53f14e8aef50c5ab17c0acbfaacaa - Sigstore transparency entry: 1357210739
- Sigstore integration time:
-
Permalink:
nazarli-shabnam/git-explain@27b7690642ed2532bac4cb2e40c00c23bfa6e70d -
Branch / Tag:
refs/tags/v2.4.0 - Owner: https://github.com/nazarli-shabnam
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@27b7690642ed2532bac4cb2e40c00c23bfa6e70d -
Trigger Event:
push
-
Statement type:
File details
Details for the file git_explain-2.4.0-py3-none-any.whl.
File metadata
- Download URL: git_explain-2.4.0-py3-none-any.whl
- Upload date:
- Size: 32.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25174384fa97bbaa5b62895f77afe644fd6d0e08d6d9b24bab1a600fe62374ef
|
|
| MD5 |
ec8ef3a20f9afadd91fee48e838c93d9
|
|
| BLAKE2b-256 |
623038a591222b2fc0d26033c68b3e3518fad6af23b5815111b44994aab31ad2
|
Provenance
The following attestation bundles were made for git_explain-2.4.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on nazarli-shabnam/git-explain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_explain-2.4.0-py3-none-any.whl -
Subject digest:
25174384fa97bbaa5b62895f77afe644fd6d0e08d6d9b24bab1a600fe62374ef - Sigstore transparency entry: 1357210745
- Sigstore integration time:
-
Permalink:
nazarli-shabnam/git-explain@27b7690642ed2532bac4cb2e40c00c23bfa6e70d -
Branch / Tag:
refs/tags/v2.4.0 - Owner: https://github.com/nazarli-shabnam
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@27b7690642ed2532bac4cb2e40c00c23bfa6e70d -
Trigger Event:
push
-
Statement type: