Skip to main content

Generate Git commit messages from staged changes using LLM

Project description

git-commit-message

Staged changes -> GPT commit message generator.

asciicast

Install (PyPI)

Install the latest released version from PyPI:

# User environment (recommended)
python -m pip install --user git-commit-message

# Or system/virtualenv as appropriate
python -m pip install git-commit-message

# Or with pipx for isolated CLI installs
pipx install git-commit-message

# Upgrade to the newest version
python -m pip install --upgrade git-commit-message

Quick check:

git-commit-message --help

Set your API key (POSIX sh):

export OPENAI_API_KEY="sk-..."

Or for the Google provider:

export GOOGLE_API_KEY="..."

Note (fish): In fish, set it as follows.

set -x OPENAI_API_KEY "sk-..."

Install (editable)

python -m pip install -e .

Usage

  • Print commit message only:
git add -A
git-commit-message "optional extra context about the change"
  • Force single-line subject only:
git-commit-message --one-line "optional context"
  • Select provider (default: openai):
git-commit-message --provider openai "optional context"
  • Select provider (Google Gemini via google-genai):
git-commit-message --provider google "optional context"
  • Limit subject length (default 72):
git-commit-message --one-line --max-length 50 "optional context"
  • Chunk long diffs by token budget (0 = single chunk + summary, -1 = disable chunking):
# force a single summary pass over the whole diff (default)
git-commit-message --chunk-tokens 0 "optional context"

# chunk the diff into ~4000-token pieces before summarising
git-commit-message --chunk-tokens 4000 "optional context"

# disable summarisation and use the legacy one-shot prompt
git-commit-message --chunk-tokens -1 "optional context"
  • Commit immediately with editor:
git-commit-message --commit --edit "refactor parser for speed"
  • Print debug info (prompt/response + token usage):
git-commit-message --debug "optional context"
  • Select output language/locale (default: en-GB):
# American English
git-commit-message --language en-US "optional context"

# Korean
git-commit-message --language ko-KR

# Japanese
git-commit-message --language ja-JP

Notes:

  • The model is instructed to write using the selected language/locale.
  • In multi-line mode, the only allowed label ("Rationale:") is also translated into the target language.

Environment:

  • OPENAI_API_KEY: required when provider is openai
  • GOOGLE_API_KEY: required when provider is google
  • GIT_COMMIT_MESSAGE_PROVIDER: optional (default: openai). --provider overrides this value.
  • GIT_COMMIT_MESSAGE_MODEL: optional model override (defaults: openai -> gpt-5-mini, google -> gemini-2.5-flash)
  • OPENAI_MODEL: optional OpenAI-only model override
  • GIT_COMMIT_MESSAGE_LANGUAGE: optional (default: en-GB)
  • GIT_COMMIT_MESSAGE_CHUNK_TOKENS: optional token budget per diff chunk (default: 0 = single chunk + summary; -1 disables summarisation)

Notes:

  • If token counting fails for your provider while chunking, try --chunk-tokens 0 (default) or --chunk-tokens -1.

AI‑generated code notice

Parts of this project were created with assistance from AI tools (e.g. large language models). All AI‑assisted contributions were reviewed and adapted by maintainers before inclusion. If you need provenance for specific changes, please refer to the Git history and commit messages.

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_commit_message-0.7.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

git_commit_message-0.7.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file git_commit_message-0.7.0.tar.gz.

File metadata

  • Download URL: git_commit_message-0.7.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for git_commit_message-0.7.0.tar.gz
Algorithm Hash digest
SHA256 27ac08e386b3179241106f3f3aee5d25ba7001caeb94b4f7c226aa0ea75eb9e0
MD5 3275db05ea9fb7f85c3c05d26de8f90d
BLAKE2b-256 5e19cb2162ea396dd6b1ad75904c9f0f7389b19548c4e95fc86831725d55db51

See more details on using hashes here.

File details

Details for the file git_commit_message-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: git_commit_message-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for git_commit_message-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 932bec0fb3253c19bab3b36b6e07961d91e0c9ab60c84637f4be3bb7828c39b4
MD5 dff0fc3645aeb4e8138ab6a0f61e854d
BLAKE2b-256 de1e345f25288bb224116bb34f75088a962ea32df16fac10a376e36f14b68e9b

See more details on using hashes here.

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