AI-powered git commit CLI — Generate meaningful commit messages using LLMs, review them interactively, then commit and push — all in one command.
- Features
- How it Works
- Installation
- Quick Start
- Configuration
- Commit Styles
- CLI Reference
- Go Library
- Contributing
- License
- Brainless Commits: Analyzes your staged changes and writes comprehensive, accurate commit messages.
- Interactive Review: Accept, reject, regenerate, or manually edit the generated message inline.
- Zero Dependencies: Single binary. No Node.js, Python, or other runtime required.
- All-in-One Flow: Stage files, generate message, commit, and push in a single
gitai commitcommand. - Interactive Picker: Select which changed files to stage using a clean terminal UI (
--pick). - Extensible: Written in Go with public packages. Easily add new LLM providers.
The standard gitai flow connects the dots between writing code and shipping it.
sequenceDiagram
participant U as User
participant CLI as gitai
participant LLM as Provider (OpenAI)
participant Git as Git
U->>CLI: `gitai commit`
CLI->>Git: Reads staged diff
Git-->>CLI: returns diff string
CLI->>LLM: Sends diff + prompt + style
LLM-->>CLI: Streams commit message
CLI->>U: Prompts for review (y/e/r/n)
alt User accepts (y)
CLI->>Git: `git commit -m`
CLI->>Git: `git push` (if auto-push enabled)
CLI-->>U: Success!
else User edits (e)
CLI->>U: Opens $EDITOR
U-->>CLI: Saves edited message
CLI->>Git: `git commit -m`
CLI-->>U: Success!
end
# Homebrew (macOS/Linux)
brew install Chifez/tap/gitai
# Scoop (Windows)
scoop install gitaiRequires Go 1.22+ installed on your machine.
go install github.com/Chifez/gitai@latest- Go to the Releases page.
- Download the binary for your OS and architecture.
- Extract and place the
gitaibinary in your$PATH.
You don't even need to run git add first! If you run gitai commit with nothing staged, it will automatically prompt you to either stage all changes or pick files interactively.
# Stage all changes and commit with an AI-generated message
gitai commit --all
# Open the interactive file picker to choose what to stage
gitai commit --pick
# Stage specific files only and commit
gitai commit src/auth.go src/middleware.go
# Standard flow: generate message for already-staged changes
git add src/
gitai commit
# Skip review, commit immediately
gitai commit --all --yes
# First push to a new remote branch
gitai commit --all --remote https://github.com/user/repo.gitThe first time you run gitai, an interactive wizard will guide you through the initial setup automatically:
No config found. Running first-time setup...
Enter your OpenAI API key: sk-...
Default model [gpt-4o-mini]: (press enter)
Commit style (conventional/simple/emoji) [conventional]:
Auto-push after commit? (y/n) [y]:
Include commit body? (y/n) [y]:
Config saved to ~/.gitai/config.yaml
Continuing with your commit...
GitAI respects the following environment variables. They override the config file but are overridden by CLI flags.
| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key (always checked first) |
GITAI_MODEL |
Override model |
GITAI_PROVIDER |
Override provider |
GITAI_STYLE |
Override commit style |
GITAI_AUTO_PUSH |
true or false |
GITAI_LANG |
Override message language |
GitAI saves its core state in ~/.gitai/config.yaml. Additional options like include_body, default_remote_name, and auto_set_upstream are also stored here.
Run gitai config list to see your current settings.
Run gitai config help to see all available commands.
Setting your API Key:
gitai config set api_key sk-...
# Or export OPENAI_API_KEY=sk-... in your environmentCustomizing Behavior:
# Change LLM Model (default is gpt-4o-mini)
gitai config set model gpt-4o
# Automatically push after committing
gitai config set auto_push true
# Change the language of the output message
gitai config set lang spanishGitAI supports multiple commit string formats out of the box. Change it using gitai config set style <style> or passing --style.
conventional(default):feat(auth): add JWT refresh token rotationsimple:Add JWT refresh token rotationemoji:feat(auth): add JWT refresh token rotation
| Flag | Description |
|---|---|
[files...] |
Files to stage before committing |
--pick, -p |
Interactive file picker to select changes |
--all, -a |
Stage all modified tracked files |
--include-untracked |
With --all, also stage untracked files |
--model |
LLM model for this commit |
--style |
Commit style: conventional, simple, emoji |
--context |
Natural language hint for the AI |
--provider |
LLM provider for this commit |
--lang |
Language for the message |
--max-length |
Max subject line characters (default: 72) |
--no-push |
Skip push entirely |
--push |
Force push even if auto_push is off |
--yes, -y |
Skip review, commit immediately |
--dry-run |
Display message only, no commit |
--remote <url> |
Add remote and push (useful for first push) |
--remote-name <n> |
Name of the remote (default: origin) |
--branch <n> |
Remote branch to push to (default: current branch) |
--force-push |
Push with --force-with-lease |
| Command | Description |
|---|---|
list |
Print all config values and sources |
get <key> |
Print a single config value |
set <key> <value> |
Update a config value |
reset |
Reset config to defaults |
path |
Print config file path |
GitAI is built to be extensible. All core packages in pkg/ are public and can be imported into your own Go tools.
import (
"github.com/Chifez/gitai/pkg/provider"
"github.com/Chifez/gitai/pkg/git"
"github.com/Chifez/gitai/pkg/prompt"
)We welcome community contributions! Whether it's reporting a bug, proposing a new feature, or submitting a Pull Request, your help is appreciated.
- Fork the Repository: Click the 'Fork' button at the top right of this page.
- Clone your Fork:
git clone https://github.com/YOUR_USERNAME/gitai.git cd gitai - Create a Branch: Create a feature branch for your work.
git checkout -b feature/amazing-feature
- Make Changes: Implement your feature or fix. Follow existing Go patterns and keep things clean!
- Run Tests: Ensure all tests pass.
go test ./... - Commit & Push:
gitai commit --all git push origin feature/amazing-feature
- Open a Pull Request: Go to the original repository and click "Compare & pull request".
If you find a bug or have a feature request, please Open an Issue. Provide as much context as possible, including OS version, gitai version, and any relevant logs.
This project is licensed under the MIT License.