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.0.tar.gz (36.7 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.0-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git_explain-2.5.0.tar.gz
  • Upload date:
  • Size: 36.7 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.0.tar.gz
Algorithm Hash digest
SHA256 384bf1635adc2face5a0107fde943f7811f31791b4702899709de3b65fc1bad4
MD5 252c7d1f2ee5b220b1cf9e2cd447d6ae
BLAKE2b-256 21ba10cce2503bc3499f277c9e8c5091029e2f19dcb5854d3954f804b2b64cf1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: git_explain-2.5.0-py3-none-any.whl
  • Upload date:
  • Size: 31.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7a572d12dd882b7285816e48f0ac14f2ad8958139b04045531e3101c483ea35
MD5 29baea19309752636893136727b25a09
BLAKE2b-256 1d3375e4bc981556a7bb36cb2f68748b40e249e03f476dd43d36a4eeb3f99601

See more details on using hashes here.

Provenance

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