Repolode
zurawiki

zurawiki/gptcommit

A git prepare-commit-msg hook that uses OpenAI models to draft commit messages from your staged changes.

Stars
2,413
Forks
81
Open issues
9
Last commit
6 days ago

What is it?

gptcommit installs as a git prepare-commit-msg hook. When you run git commit as usual, it reads the staged diff, sends it to an OpenAI model, and fills in the commit message, which you can edit before committing.

The tool is configured through a user config file, a per-repository config, or GPTCOMMIT__ environment variables, and the OPENAI_API_KEY and OPENAI_API_BASE variables are also supported. Users can change the model, API base URL, proxy, retry count, and output language, with support for English, Simplified Chinese, Traditional Chinese, and Japanese. Conventional commit prefixes can be enabled, and the prompts can be customized.

For large changes, file_ignore accepts Git-style patterns to exclude lock files, minified assets, or generated code from the diff. Empty or fully ignored staged changes leave the message untouched and do not call the API. Running with --verbose shows progress and skipped files. It is available through cargo and Homebrew.

Key features

  • 01Generates commit messages from staged diffs using OpenAI models.
  • 02Installs as a git prepare-commit-msg hook with a single command.
  • 03Supports English, Simplified Chinese, Traditional Chinese, and Japanese output.
  • 04Filters out files with Git-style ignore patterns such as lock files and minified JS.
  • 05Layers user, repository, and environment-variable configuration with config get/set commands.
  • 06Supports custom API base URLs and proxies, and can enable Conventional Commits prefixes.

Use cases

  • Drafting commit messages for everyday changes without writing them by hand.
  • Keeping commit history consistent by using Conventional Commits prefixes across a team.
  • Writing commit messages in a non-English language such as Chinese or Japanese.
  • Using a self-hosted or compatible OpenAI-style endpoint through a custom API base URL.

Quick start

  1. 1

    Install the gptcommit binary with cargo

    cargo install --locked gptcommit
  2. 2

    In your git repository, install the prepare-commit-msg hook (you will need an OpenAI API key)

    gptcommit install

Things to know

  • Requires an OpenAI API key with available credits, and usage is billed by OpenAI.
  • Staged diffs are sent to OpenAI's API to generate messages.

In collections

Topics

FAQ

What is gptcommit?
A git prepare-commit-msg hook that uses OpenAI models to draft commit messages from your staged changes. gptcommit installs as a git prepare-commit-msg hook. When you run git commit as usual, it reads the staged diff, sends it to an OpenAI model, and fills in the commit message, which you can edit before committing.
Is gptcommit free to use? What license does it have?
gptcommit is open source under the MIT license. Check the license terms before using it in commercial products.
Is gptcommit still maintained?
Actively maintained. The last commit to gptcommit was on Nov 1, 2026.
What can I use gptcommit for?
Drafting commit messages for everyday changes without writing them by hand. Keeping commit history consistent by using Conventional Commits prefixes across a team. Writing commit messages in a non-English language such as Chinese or Japanese. Using a self-hosted or compatible OpenAI-style endpoint through a custom API base URL.
How do I install gptcommit?
Install the gptcommit binary with cargo: cargo install --locked gptcommit In your git repository, install the prepare-commit-msg hook (you will need an OpenAI API key): gptcommit install
Where can I get gptcommit?
The source code and installation instructions are on GitHub: https://github.com/zurawiki/gptcommit

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects