Skip to content

git-msg

GitHub →

git-msg reads your staged diff, current branch, and recent commit log, sends them to an LLM via a prompt template, and drops the generated message into an interactive TUI where you can confirm, edit inline, open $EDITOR, or abort — before anything is committed. It supports Anthropic, OpenAI, Gemini, and Ollama, and can install itself as a prepare-commit-msg git hook.

git-msg has no tagged release yet; this documents the current main. The build-time version is shown by git-msg --version.
git add .
git-msg generate
  Generated commit message:
  > Use as-is
    Edit inline
    Open $EDITOR
    Abort

feat(config): add XDG-compliant path resolution via internal/dirs

Install

brew tap madstone-tech/tap
brew install git-msg

Or with Go:

go install github.com/madstone-tech/git-msg@latest

Or download a binary from GitHub Releases.


First run

The first time you run any git-msg command, a setup wizard launches automatically:

  git-msg — first-run setup

  Select LLM provider
  > Anthropic (Claude)
    OpenAI (GPT)
    Google Gemini
    Ollama (local)

For cloud providers you choose a model and enter an API key. Keys are stored in the system keychain (service git-msg), never in config files. For Ollama, git-msg queries ollama list and presents a model picker.


Providers

ProviderDefault modelAPI key requiredKey env-var fallback
anthropicclaude-haiku-4-5YesGIT_MSG_ANTHROPIC_API_KEY
openaigpt-4o-miniYesGIT_MSG_OPENAI_API_KEY
geminigemini-1.5-flashYesGIT_MSG_GEMINI_API_KEY
ollamallama3No

If no key is found in the keychain, git-msg falls back to the matching GIT_MSG_<PROVIDER>_API_KEY environment variable. Override the provider for a single run:

git-msg generate --provider ollama

Git hook integration

Install as a prepare-commit-msg hook so generation happens automatically on git commit:

git-msg hook install            # local repo
git-msg hook install --global   # globally via git core.hooksPath

Uninstall:

git-msg hook uninstall
git-msg hook uninstall --global

Configuration

Config file: ~/.config/mdstn/git-msg/config.toml (XDG path on all OSes; override the base with XDG_CONFIG_HOME). User prompt templates live in ~/.config/mdstn/git-msg/prompts/.

[provider]
name  = "anthropic"
model = "claude-haiku-4-5"

[ollama]
host = "http://localhost:11434"

[prompt]
default = "conventional"

[hook]
global = false

Read and set values via the CLI:

git-msg config show
git-msg config get provider.model
git-msg config set provider.name ollama
git-msg config set provider.model llama3

Prompt templates

Templates use Jinja2-style syntax rendered by the ason engine (not literal Jinja2). git-msg ships one embedded template, conventional, following the Conventional Commits spec. Three variables are available: {{ diff }}, {{ branch }}, and {{ log }}.

git-msg prompt list
git-msg prompt show conventional
git-msg prompt edit my-template      # opens in $EDITOR
git-msg prompt reset conventional    # restore the embedded default

CLI reference

CommandDescription
git-msg generateGenerate a commit message from the staged diff
git-msg config showPrint the full resolved configuration
git-msg config get <key>Print one config value
git-msg config set <key> <value>Set a config value
git-msg prompt listList available prompt templates
git-msg prompt show <name>Print a template
git-msg prompt edit <name>Edit a template in $EDITOR
git-msg prompt reset <name>Reset a template to its embedded default
git-msg hook installInstall the prepare-commit-msg hook (--global for git-wide)
git-msg hook uninstallRemove the git hook (--global for git-wide)
git-msg completion <bash|zsh|fish>Generate a shell completion script

Global flag: --version prints the build-time version.

generate flags:

FlagDescription
--dry-runPrint the generated message and skip the review TUI / commit
--provider <name>Override the configured LLM provider for this run
--template <name>Use a specific prompt template for this run