Model or dataset
zurawiki/gptcommit avatar
zurawiki/gptcommit

gptcommit: an OpenAI-backed prepare-commit-msg hook for Git

A git prepare-commit-msg hook for authoring commit messages with LLMs.

2,418 stars80 forksRustMIT

At a glance

What is it?
gptcommit is a Rust CLI that installs a Git prepare-commit-msg hook and drafts commit messages with an OpenAI model. It is convenient for solo work and small diffs, and awkward when your repository already uses commit templates.
Who is it for?
Adopt gptcommit if you work in a repository without a commit template, you already pay for OpenAI API access, and you want a drafted message to edit rather than a blank editor. Skip it if your workflow depends on commit.template, if you need a model other than OpenAI's, or if you cannot send diff content to a third party.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 6 days ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 1, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What gptcommit actually removes from your day

The blank commit message editor is the problem. gptcommit is a git prepare-commit-msg hook, which is the hook Git runs after it has staged the change but before it opens the editor for the message. The README describes the effect plainly: you run git commit as usual, and the hook fills the message in with text generated by a large language model. You can edit the result before the commit is recorded.

The target user is a developer who already commits often and does not enjoy writing the summary line. The README frames the goal as letting you "focus on writing code" and generating "clear, comprehensive and descriptive commit messages." That is a narrow scope on purpose. gptcommit does not review code, does not decide what to stage, and does not push. It only writes the text that goes into the message field.

One design detail shapes everything else: the tool is a hook, not a wrapper. You keep typing git commit, and the integration lives in your repository's hook directory.

The N+2 prompt model and where your diff goes

The README explains the request pattern directly: gptcommit issues N+2 prompts, where N is the number of modified files that have diffs under the max_token_limit. The two extra prompts are the title and the summary.

That means cost scales with the number of changed files, not with the size of the commit message. The README is candid about this: the generated tokens are predictable because a commit message is short, but the diff data sent to the API can be large. It lists two ways to reduce the bill, switching to another model with the openai.model setting and shrinking the prompt and diff data. That is an honest framing of a real trade-off, and it is the part of the design most worth understanding before you install anything.

Configuration is layered. Settings are read from $HOME/.config/gptcommit/config.toml, then from $GIT_ROOT/.git/gptcommit.toml for the repository, then from environment variables prefixed with GPTCOMMIT__*. The README states that OPENAI_API_KEY and OPENAI_API_BASE take the highest precedence, which exists so the tool stays compatible with other OpenAI clients. The full key list is available through gptcommit config keys rather than being enumerated in the README.

Installing gptcommit and making your first commit

The README recommends cargo. This builds the binary and installs it on your PATH:

bash
cargo install --locked gptcommit

On macOS there is a Homebrew formula in the same project's tap:

bash
brew install zurawiki/brews/gptcommit

You still need to install the hook inside each repository you want to use it in. Run this from the repository root and supply an API key when prompted:

bash
gptcommit install

If you would rather not be prompted, or you want the key scoped to one repository instead of your home directory, the README gives both forms:

bash
gptcommit config set openai.api_key sk-...
gptcommit config set --local openai.api_key sk-...

After that, stage something and run git commit. The hook fires, the message field is prefilled, and you accept or edit the text before the commit is created. The README notes the default model is the fastest and most cost-effective OpenAI option available, so a first run on a small diff is a cheap way to see the output style.

The template and amend behaviour that surprises people

The most common complaint in the README's own FAQ is that the hook does not run. The answer is in the design: the hook only runs for new commits. If a commit template is set, or the commit is being amended, gptcommit skips by default.

The reason is deliberate. The tool detected that you are supplying your own template, so it refuses to overwrite it. The README tells you to clear the template with git config --local commit.template if you want the hook to fire. That is a sensible default for teams with a mandated template, and an annoying one for anyone who set a template long ago and forgot about it.

Amending has a separate switch. You can let gptcommit summarize amended commits with:

bash
gptcommit config set allow-amend true

A second limitation is model lock-in. The configuration is built around OpenAI, and the README points at OpenAI's model list and notes you can bring a fine-tuned model. If your organisation routes traffic through a different vendor, this is the wrong tool, even though a custom base URL and a proxy setting are supported.

Output language, proxies and the rest of the config surface

gptcommit defaults to English and ships four language codes: en, zh-cn, zh-tw, and ja. You change it with the output.lang key:

bash
gptcommit config set output.lang zh-cn

That list is short and the README presents it as the current set, so do not assume an unlisted locale will work. If you commit in a language outside those four, the model will still produce something, but the tool is not promising to.

Two other settings matter in restricted networks. openai.api_base points the client at a different endpoint, and openai.proxy routes requests through an HTTP proxy. Both are set the same way as the API key, and both can be overridden per repository with --local. The environment variable forms, GPTCOMMIT__OPENAI__API_BASE and GPTCOMMIT__OPENAI__PROXY, take precedence over the files.

There is also a VSCode extension listed under Derived Works in the README, built by a different author, for people who would rather not leave the editor for the commit flow.

How gptcommit compares with writing the message yourself

The obvious alternative is not another tool. It is the plain Git workflow: run git commit, write the message, close the editor. That approach costs nothing, sends no diff anywhere, and produces a message that reflects intent the diff alone cannot show, such as why a change was made rather than what changed.

A closer alternative is the commit convention tooling built into editors and Git clients, which typically offers a template, a linter or a guided prompt rather than a generated message. The difference in approach is where the intelligence sits. A template enforces structure and leaves the words to you. gptcommit reads the diff and writes the words, leaving structure to the model's prompt.

That distinction decides the fit. If your team's problem is inconsistent message formatting, a template solves it deterministically. If your problem is the effort of writing the message at all, gptcommit addresses that, at the cost of an API call per commit and a dependency on an external service being reachable when you commit.

Maintenance, licence and what a hook costs you to keep

The repository is not archived. The last push was on 2026-04-19, and the most recent release listed is v0.5.17 from 2024-10-12, with v0.5.16 before it in January 2024 and v0.5.14 in October 2023. The gap between the last release and the last push is worth noting if you depend on tagged versions rather than the main branch.

Upgrade cost is low but not zero. The binary is installed with cargo install --locked gptcommit, and the lockfile pins the dependency tree, so an upgrade is a reinstall. The hook itself lives in the repository, so each repository where you ran gptcommit install may need the hook refreshed after an upgrade. The README documents install and uninstall as separate subcommands, which gives you a clean way to back out.

The licence is MIT, stated in both the README and Cargo.toml. That is permissive and imposes no conditions beyond keeping the copyright notice, but it says nothing about the OpenAI terms that govern the API calls the tool makes. Those are a separate agreement, and the README does not discuss them.

Editorial conclusion

Adopt gptcommit if you work in a repository without a commit template, you already pay for OpenAI API access, and you want a drafted message to edit rather than a blank editor. Skip it if your workflow depends on commit.template, if you need a model other than OpenAI's, or if you cannot send diff content to a third party. Before rolling it out, run gptcommit config keys to see the full option set and check that GPTCOMMIT__OPENAI__MODEL points at a model you are willing to pay for.

Frequently asked questions

What does gptcommit do with my Git commits?

It installs as a prepare-commit-msg hook, so when you run git commit it drafts the commit message with an OpenAI model and leaves it in the message field for you to edit before the commit is recorded.

Why is the gptcommit hook not running when I commit?

By default the hook only runs for new commits. If a commit template is set or the commit is being amended, gptcommit skips, and the README says to clear the template with git config --local commit.template or enable amending with allow-amend.

How do I reduce the OpenAI cost of using gptcommit?

The README states that gptcommit issues N+2 prompts, where N is the number of modified files with diffs under max_token_limit, and suggests switching model with openai.model or reducing the prompt and diff data sent.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. Releases
  5. zurawiki/gptcommit on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/zurawiki-gptcommit.svg)](https://hysenlabs.com/projects/zurawiki-gptcommit)