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.
--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, 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 ..

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.5.1.tar.gz (37.2 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.5.1-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file git_explain-2.5.1.tar.gz.

File metadata

  • Download URL: git_explain-2.5.1.tar.gz
  • Upload date:
  • Size: 37.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for git_explain-2.5.1.tar.gz
Algorithm Hash digest
SHA256 fa35c56b9c13ee8bbec080784626040c6a8f91a8b9e2d95fdab96db6cdf70cf0
MD5 5debb7742789f4a6dad3653a8c60c8d4
BLAKE2b-256 8ea8e4e22c6b9886689f72e5258cd75ba6d4097742b24fea8780244fabeface9

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_explain-2.5.1.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.5.1-py3-none-any.whl.

File metadata

  • Download URL: git_explain-2.5.1-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for git_explain-2.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f1419a12ab3de26bc68ae7d4ce75d0229374929d0192a812c88942252144ffe7
MD5 fd14b5fd25dc14b150c0f578ef3f63f4
BLAKE2b-256 edbf83a37612c1d3863ca915034969a67e93f0c83429286cfdb6b761d5574ec3

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_explain-2.5.1-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