Skip to main content

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.

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 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-litegemini-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

Sponsored by GitAds

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_explain-2.4.0.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_explain-2.4.0-py3-none-any.whl (32.0 kB view details)

Uploaded Python 3

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

Hashes for git_explain-2.4.0.tar.gz
Algorithm Hash digest
SHA256 ddf73d2da481d690bb753cdd2e8db71988d53f14e8aef50c5ab17c0acbfaacaa
MD5 a7ab8bf02cd3cadc84c539e63ec28776
BLAKE2b-256 8b6f597c6b2e67a0a699d5b7e7d55e8f7a724a2d9cddae1784547b41b48494b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_explain-2.4.0.tar.gz:

Publisher: pypi-publish.yml on nazarli-shabnam/git-explain

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for git_explain-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25174384fa97bbaa5b62895f77afe644fd6d0e08d6d9b24bab1a600fe62374ef
MD5 ec8ef3a20f9afadd91fee48e838c93d9
BLAKE2b-256 623038a591222b2fc0d26033c68b3e3518fad6af23b5815111b44994aab31ad2

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page