Skip to main content

Generate Git commit messages from staged changes using OpenAI GPT

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

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"
  • 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"
  • 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
  • GIT_COMMIT_MESSAGE_MODEL or OPENAI_MODEL: optional (default: gpt-5-mini)
  • 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)

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.6.0.tar.gz (12.9 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.6.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git_commit_message-0.6.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.6.0.tar.gz
Algorithm Hash digest
SHA256 9f712a259a46c0796b9d96e85ed728ce6f5b0267d02a510b99586adfae37bbf3
MD5 7edd04fee4ba5e025e416290b086efdf
BLAKE2b-256 129b44fc0896ee4dc6a23cb9c4a112a634cbfe5fdd02987561345db0de17ab8b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: git_commit_message-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 378873865de4745baec34660e32d25108ccbbd18fb164808240bb071b62d7baa
MD5 d0dd62eda380ae874a417f20c09f6908
BLAKE2b-256 9f09d5a47fc1ca39abc60588c24e13f4ab1e6c46f51152206019bef012da7979

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