Git Tools

Lazygit Added AI Commit Messages

All articles
🦥📝

One keybind. Staged diff in, conventional commit out.

If you've been living under a rock, lazygit shipped a quiet little update that buries the lede: hit g on a staged diff and it writes the commit for you. Locally. No OpenAI bill, no telemetry.

The Setup

It's a custom command tied to your local LLM of choice. I wired mine to Ollama on the M4 — it streams a conventional-commit message back in under a second across a multi-project monorepo diff.

# ~/.config/lazygit/config.yml
customCommands:
  - key: 'g'
    context: 'files'
    description: 'AI commit message'
    command: >
      git diff --cached | ollama run llama3.2 "Write a conventional
      commit message for this diff. Subject under 60 chars. No body
      unless the why is non-obvious." | git commit -F -
    loadingText: 'thinking...'

The Money Pattern

The trick is piping git diff --cached straight into the model and git commit -F - on the other side. No prompt UI, no copy-paste tango. Just stage, hit g, done.

# stage hunks the lazygit way then fire
# space to stage, g to generate, enter to confirm

# bonus: tighter prompt for monorepo work
ollama run llama3.2 "Conventional commit. Prefix with scope from
the first changed path segment (e.g. feat(velocity8.5): ...).
Diff follows:" < <(git diff --cached)

The Catch

You need your own LLM running. Ollama is the path of least resistance — pull llama3.2 or qwen2.5-coder and you're good. Plot twist: on cold start the first commit takes 4 seconds while the model loads. After that it's instant.

The Verdict

This is the lazygit feature I didn't know I needed. Cursor and Claude Code already write my code — letting a 3B model name the commit closes the loop. Drop it in your config tonight. Do not @ me when you stop typing "fix stuff" at 2am.

Let us make some quick suggestions?
Please provide your full name.
Please provide your phone number.
Please provide a valid phone number.
Please provide your email address.
Please provide a valid email address.
Please provide your brand name or website.
Please provide your brand name or website.