gptcommit logo

gptcommit

Free

Git hook for authoring commit messages.

FreeFree tier
Type
Open Source

About gptcommit

gptcommit is a git prepare-commit-msg hook that automatically generates clear, comprehensive, and descriptive commit messages using large language models (LLMs) such as OpenAI's GPT. It integrates seamlessly into your Git workflow: simply run git commit as usual, and the hook generates a commit message based on your staged changes. The tool supports extensive configuration via a TOML file, allowing users to set API keys, choose between different OpenAI models, customize the API base URL, and specify the language for commit message output. It can be installed via Cargo or Homebrew and is designed to save developers time by removing the friction of writing commit messages manually.

Key Features

Automatically generates commit messages from staged changes using an OpenAI language model
Works as a git prepare-commit-msg hook, invoked on `git commit`
Highly configurable via $HOME/.config/gptcommit/config.toml, repo-specific config, and environment variables
Supports setting OpenAI API key and custom API base URL
Allows selection of different OpenAI models (e.g., GPT-3.5, GPT-4, or custom fine-tuned models)
Configurable output language (defaults to English)
Installable via cargo (`cargo install --locked gptcommit`) or Homebrew (`brew install zurawiki/brews/gptcommit`)
Open source (MIT license) and free to use (requires own OpenAI API key)

Pros & Cons

Pros
  • Saves developer time by automating commit message generation
  • Generates descriptive and structured commit messages based on code changes
  • Highly configurable to match individual or team preferences (model, API, language)
  • Works transparently as a Git hook – no changes to existing commit commands
  • Open source and free with easy installation via package managers
  • Supports multiple OpenAI models and custom API endpoints
Cons
  • Requires a valid OpenAI API key and sufficient credits in the OpenAI account
  • Dependent on external API availability and network connectivity
  • Generated messages may sometimes be inaccurate or require manual editing
  • Limited to generating commit messages; does not assist with other Git tasks
  • Not suitable for fully offline use without a local LLM setup (not natively supported)

Best For

Generating clear and consistent commit messages for personal projectsAutomating commit message writing in team repositories to maintain a uniform styleReducing time spent on writing commit messages during rapid development or large programming sessionsIntegrating with existing Git workflows without changing developer habitsExperimenting with different LLM models to find the best commit message quality

FAQ

How do I install gptcommit?
gptcommit can be installed via Cargo with `cargo install --locked gptcommit` or on macOS via Homebrew with `brew install zurawiki/brews/gptcommit`.
How do I set my OpenAI API key?
Use `gptcommit config set openai.api_key sk-...` to persist your key, or set the `OPENAI_API_KEY` environment variable. You can also use `GPTCOMMIT__OPENAI__API_KEY` for per-repo configuration.
Can I use a different model than the default?
Yes, you can set a custom model using `gptcommit config set openai.model your-model-name`. This includes public OpenAI models or your own fine-tuned models.
Is gptcommit free to use?
gptcommit is open source and free to use, but you must provide your own OpenAI API key and pay for API usage according to OpenAI's pricing.
How do I customize the language of the commit messages?
You can set the output language using `gptcommit config set output.language <language-code>` (e.g., `ja` for Japanese).