An AI-powered git commit message generator written in Rust.
Download and install directly from GitHub Releases:
# Linux (amd64)
curl -L https://github.com/CJHwong/rs-git-msg/releases/latest/download/rs-git-msg-linux-amd64 -o /usr/local/bin/rs-git-msg && chmod +x /usr/local/bin/rs-git-msg
# macOS (amd64)
curl -L https://github.com/CJHwong/rs-git-msg/releases/latest/download/rs-git-msg-macos-amd64 -o /usr/local/bin/rs-git-msg && chmod +x /usr/local/bin/rs-git-msggit clone https://github.com/CJHwong/rs-git-msg.git
cd rs-git-msg
./scripts/install.shcargo build --release
cp target/release/rs-git-msg ~/.local/bin/ # or /usr/local/bin/# Stage some changes, then generate a commit message
git add .
rs-git-msgUsage: rs-git-msg [OPTIONS]
Options:
-n, --number <NUMBERS> Number of commit messages to generate (1-5) [default: 1]
-i, --instructions <INSTRUCTIONS>
Additional context or instructions for the AI
-v, --verbose Enable verbose output
-p, --provider <PROVIDER> AI provider to use [default: ollama] [possible values: ollama, openai, gemini]
-m, --model <MODEL> Model name to use (defaults to provider's default)
-k, --api-key <API_KEY> API key for the provider (not needed for Ollama)
-u, --api-url <API_URL> API base URL (defaults to provider's standard URL)
--diff-alg <DIFF_ALG> Diff algorithm to use [default: default] [possible values: default, patience, minimal, difftastic]
-h, --help Print help
-V, --version Print versionOllama (default, no API key needed):
# Install Ollama: https://ollama.ai/download
ollama pull qwen3
rs-git-msg # uses default model
rs-git-msg -m qwen2.5-coder # specify a different modelOpenAI:
rs-git-msg -p openai -m gpt-4o-mini -k your_api_keyGemini:
export GEMINI_API_KEY="your-api-key"
rs-git-msg -p gemini
rs-git-msg -p gemini -m gemini-2.5-flash # specify model# Generate multiple options
rs-git-msg -n 3
# Add context for the AI
rs-git-msg -i "This fixes the login timeout bug"
# Verbose output for debugging
rs-git-msg -v| Variable | Description |
|---|---|
GEMINI_API_KEY |
API key for Gemini (also used for OpenAI if no -k flag is passed) |
RS_GIT_MSG_API_KEY |
Deprecated. Use GEMINI_API_KEY instead. Still works but emits a warning. |
Run the setup script to add a keybinding (Ctrl+G / Cmd+G on macOS) that generates commit messages directly in lazygit:
./scripts/setup-lazygit.shAdd to your lazygit config.yml (~/Library/Application Support/lazygit/config.yml on macOS, ~/.config/lazygit/config.yml on Linux):
customCommands:
- key: <c-g>
prompts:
- type: input
title: Additional Instructions (optional)
key: Instructions
initialValue: ""
- type: menuFromCommand
title: AI Commit Messages
key: Msg
command: 'rs-git-msg -n 5 {{if .Form.Instructions}}-i "{{.Form.Instructions}}"{{end}}'
command: git commit -m "{{.Form.Msg}}"
context: 'files'
description: 'Generate commit message using rs-git-msg'
loadingText: 'Generating commit messages...'
stream: falserm ~/.local/bin/rs-git-msg # or: sudo rm /usr/local/bin/rs-git-msg
rm -rf ~/.config/rs-git-msg # optional: remove configOr use the uninstall script: ./scripts/uninstall.sh
Contributions are welcome! See CONTRIBUTING.md for development setup, testing, and submission guidelines.
