gptcommit writes the commit message, unless a template or an amend steps in
A git prepare-commit-msg hook for authoring commit messages with LLMs.
At a glance
- What is it?
- A Rust prepare-commit-msg hook that summarizes staged files with an OpenAI model, and a README whose sharpest details are the ones it mentions in passing: an ignore list that stopped matching substrings, four configuration layers instead of three, a per-commit prompt count with no figure attached, and an API key written to a plain text file.
- Who is it for?
- gptcommit is a small Rust hook whose gaps sit in the documentation rather than the plumbing: a precedence list with two environment layers it never mentions, an ignore list that stopped matching substrings, an ignore file that is not git's own, and a cost model expressed only as N+2 prompts.
- 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 21 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 November 22, 2026, and from our analysis. They are not legal advice.
Star history
- zurawiki/gptcommit2,411 ★ · -8
| Repository | 2026-09-10 | 2026-11-22 |
|---|---|---|
| zurawiki/gptcommit | 2.4k | 2.4k |
-8 Stars in the last 73 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The hook steps aside for templates and amends by default
gptcommit installs itself as a git prepare-commit-msg hook, so the message is written while git is assembling the commit, rather than by a command you have to remember. Two situations are skipped without asking. The first is an amend: by default the hook runs only for new commits, and `gptcommit config set allow-amend true` is the switch that changes that.
The second is a commit template. When the repository sets one, the hook notices that the user is supplying their own and stays out of the way, which is a defensible choice, but the paragraph meant to explain what happens next ends mid sentence: because the githook detected the user is supplying their own template, we make, and nothing follows it. So the one behavior a template-using team is most likely to hit is the one with the least explanation attached.
A third skip is quieter and cheaper. Empty or fully ignored staged changes leave the commit message untouched and do not require an API key, so a staged nothing costs nothing. Generation itself is quiet by default too, and `gptcommit --verbose` is what surfaces progress, skipped files, and which ignore rule matched each one. That flag is the only window the tool opens during a commit, which makes it the first thing to turn on when you are evaluating the hook.
file_ignore stopped matching substrings and never reads .gitignore
The ignore list changed meaning under anyone who already had one. Patterns are now Git style and matched against repository relative paths: `Cargo.lock` matches that filename at any depth, `/generated/` matches a root directory, and `**/*.min.js` catches minified JavaScript. Later patterns win, and `!` re-includes a file an earlier pattern matched.
What breaks an existing setup is the substring behavior. `lock` now matches only that complete filename or directory name, so a config written years ago needs explicit wildcards such as `*lock*` to keep matching names that merely contain lock. The guide states that as a current rule with a migration hint, and does not say which release made the switch.
file_ignore = ["Cargo.lock", "**/*.min.js", "vendor/*", "!vendor/README.md"]The second half of the rule matters more than the pattern syntax. These rules are separate from git's own ignore files: staged files are selected using `file_ignore`, not by reading `.gitignore`. A repository that keeps generated bundles out of `.gitignore` still has every one of them summarized and sent for billing unless the same pattern is repeated here. The only feedback is the skipped file and its matching rule, and only under `--verbose`.
Config precedence stacks two environment layers above the repository file
Configuration is read from three places, in an order given as user settings from `$HOME/.config/gptcommit/config.toml`, then the repository clone at `$GIT_ROOT/.git/gptcommit.toml`, then environment variables starting with `GPTCOMMIT__*`. Two later sections add a layer that list never mentions. The API key and API base sections both close by saying the plain `OPENAI_API_KEY` and `OPENAI_API_BASE` variables are supported for compatibility with other OpenAI clients, and that this will take the highest precedence. A shell export can therefore outrank a value you deliberately wrote into your own config file.
gptcommit config set --local openai.retries 2
gptcommit config get openai.retries
gptcommit config set --local file_ignore '["Cargo.lock", "yarn.lock"]'
gptcommit config delete --local openai.retriesThose four lines double as the documentation for how editing works. Set and delete touch only the selected key and preserve other entries and their comments, and deleting an override restores the value from lower priority configuration. `config get` prints strings without quotes and other values as TOML. The key used in the example, `openai.retries`, is never explained anywhere else, so its range and its default are unknowable from the guide alone. Output language is a separate setting, `output.lang`, with four locale codes: en, zh-cn, zh-tw and ja.
The base URL block repeats the API key block and ends mid sentence
The custom base URL section is a copy of the section above it with two words changed. It opens by telling you to persist your OpenAI key, which is the key section's instruction, then gives the two commands you would expect for a URL, `gptcommit config set openai.api_base https://...` for the user config and the same command with `--local` for the repository config. Its environment sentence is also unfinished: you can also config this setting via `GPTCOMMIT__OPENAI__API_BASE` or, and the line stops at the or.
What that leaves is a proxy setting with no environment variable at all. The proxy section gives one command, `gptcommit config set openai.proxy "my_http_proxy...."`, and stops there, while the key, base URL and model sections each document a `GPTCOMMIT__` prefixed variable. The dependency list shows reqwest built with the socks feature among others, so the transport can carry SOCKS traffic, yet the guide never says which URL schemes the proxy value accepts. Anyone pointing the hook at a proxy has one line of documentation and a crate feature to infer the rest from.
N plus two prompts per commit, with no figure attached
The billing section is the only place the guide does arithmetic, and it does it in variables. gptcommit issues N+2 prompts, where N is the number of modified files with diffs under the `max_token_limit`, and the other two prompts are the title and the summary. OpenAI bills tokens both sent and generated; the note observes that generated tokens are fairly predictable because a commit message is only so big, while the sent side is where diff data goes.
The remedy is two sentences: switch to a different model with the `openai.model` option, or reduce the side of prompts and diff data sent to OpenAI, written exactly that way in the text. No figure appears for either side, and `max_token_limit` is named without a configuration key or a default value anywhere in the visible documentation.
The numbers that do exist sit in the usage section instead: the default model `gpt-6-luna` runs with low reasoning effort to favor speed, each request shares a 2,048-token limit between reasoning and output, file summaries run with at most four concurrent requests, and a failed summary stops generation instead of silently omitting that file from the message.
Two install routes and a plaintext key in a config file
There are two documented ways to get the binary, and they are not obviously the same artifact. Cargo is the recommended route, macOS has a tap, and only after the binary exists does `gptcommit install` wire it into the repository as the prepare-commit-msg hook, which is also why an OpenAI key is required to finish installation. The hook template ships in the repository root as a file named `prepare-commit-msg`. Nothing in the guide says how the crates.io release and the tap are kept in step, so two machines can install by different routes and end up on different versions.
cargo install --locked gptcommit
brew install zurawiki/brews/gptcommitThe key is stored as plain text. `gptcommit config set openai.api_key sk-...` writes it into `$HOME/.config/gptcommit/config.toml`, the `--local` form writes it into `.git/gptcommit.toml` inside the clone, and the `.env.example` at the repository root shows the same variable as `OPENAI_API_KEY`. There is no mention of a system keychain, of the permissions on either config file, or of what `gptcommit install` does with a key it already has. Those are the details to settle before running it on a shared machine.
Version 0.6.0 matches the newest tag after a two year gap
The release history has an odd shape. v0.5.16 shipped on 2024-01-30, v0.5.17 on 2024-10-12, and then nothing until v0.6.0 on 2026-09-24, with the last push to main dated 2026-09-25. The current line is therefore one version step ahead of the patch series and close to two years newer than it, which means the behavior notes in the guide, not the version numbers, are what tell you whether something changed under you. The `file_ignore` substring switch described above is the clearest case: it is documented as a present tense rule with a migration hint, not as a dated entry tied to a release.
The crate manifest is at least consistent with that release. `Cargo.toml` declares version 0.6.0, edition 2021 and a `rust-version` of 1.88, and names the same binary the hook installs. The dependency names line up with the behaviors described above: tera renders prompt templates, matching the prompts directory in the tree; `tiktoken-rs` counts tokens; `ignore` is a gitignore style matcher, which is what `file_ignore` is documented to use; and `toml_edit` is the reason a config write can touch one key and leave the rest of the file, comments included, intact.
Editorial conclusion
gptcommit is a small Rust hook whose gaps sit in the documentation rather than the plumbing: a precedence list with two environment layers it never mentions, an ignore list that stopped matching substrings, an ignore file that is not git's own, and a cost model expressed only as N+2 prompts. The useful behaviour is also the easy to miss behaviour: nothing is sent when nothing survives file_ignore, a failed file summary stops the run instead of quietly dropping a file, and --verbose is the only window into either. Check your commit.template setting before blaming the hook, compare the version cargo gives you against the Homebrew tap if you use one, and read where openai.api_key lands before running install on a shared machine.
Frequently asked questions
Does gptcommit need an OpenAI API key to run?
For anything that reaches the model, yes, and the installation step itself asks for one. Empty or fully ignored staged changes are the exception: they leave the commit message untouched and do not require an API key at all.
Which model does gptcommit use by default, and how large is one request?
The default is gpt-6-luna with low reasoning effort to prioritize speed, and a 2,048-token limit shared by reasoning and output per request. The model can be replaced with the openai.model setting, and existing model overrides are preserved.
Why did gptcommit skip writing my commit message?
By default the hook runs only for new commits, so an amend is skipped until allow-amend is set to true. A configured commit template also makes it step aside, and the paragraph explaining that case ends mid sentence. Fully ignored staged changes are skipped without an API key.
Which languages can gptcommit write commit messages in?
English by default. The output.lang setting selects among the four locale codes the guide lists: en, zh-cn, zh-tw and ja.
How many prompts does one gptcommit run send to OpenAI?
The design issues N+2 prompts, where N is the number of modified files with diffs under max_token_limit, and the remaining two cover the title and the summary. File summaries run with at most four concurrent requests, and a failed summary stops generation.
Where does gptcommit keep the OpenAI API key?
In a plain text config file. gptcommit config set openai.api_key writes it to $HOME/.config/gptcommit/config.toml, and the --local form writes it to .git/gptcommit.toml in the clone. The plain OPENAI_API_KEY environment variable takes the highest precedence.
Official sources
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.
[](https://hysenlabs.com/projects/zurawiki-gptcommit)Star history chart for your README
[](https://hysenlabs.com/projects/zurawiki-gptcommit)Was this useful?