Git AI enhances your Git workflow with AI-powered features.
- git ai commit: Generates commit messages from staged changes- Create relevant, well-formatted commit messages
- Provide interactive approval with edit option
- Commit automatically with --autoflag
- Add detailed descriptions with --with-descriptions
- Control format with --conventionaland--no-conventionalflags
 
- git ai branch: Generates meaningful branch names from user input- Create descriptive branch names based on your description
- Check existing local and remote branches for naming conventions
- Provide interactive approval with edit option
- Create branch automatically with --autoflag
- Print branch name only without creating with the option menu
 
- git ai config: Manages LLM settings- Set up API keys for your preferred provider
- Offer various models (OpenAI, Anthropic, Ollama, etc.)
- Support custom endpoints for self-hosted options
- Enable custom providers through API configuration
 
curl -fsSL https://raw.githubusercontent.com/recrsn/git-ai/main/install.sh | bashThis will download and install the latest release to ~/.local/bin/git-ai.
# Create ~/.local/bin if it doesn't exist
mkdir -p ~/.local/bin
# Download the latest release for your platform
# Replace OS with darwin/linux and ARCH with amd64/arm64 as needed
curl -L -o ~/.local/bin/git-ai https://github.com/recrsn/git-ai/releases/latest/download/git-ai-OS-ARCH
# Make executable
chmod +x ~/.local/bin/git-ai
# Ensure ~/.local/bin is in your PATH
# Add to your shell profile file (.bashrc, .zshrc, etc.) if needed:
# export PATH="$PATH:$HOME/.local/bin"
# Configure your LLM settings
git ai config# Using go install
go install github.com/recrsn/git-ai@latest
# OR clone and build
git clone https://github.com/recrsn/git-ai.git
cd git-ai
go build
mkdir -p ~/.local/bin
cp git-ai ~/.local/bin/
# Ensure ~/.local/bin is in your PATH
# Add to your shell profile file (.bashrc, .zshrc, etc.) if needed:
# export PATH="$PATH:$HOME/.local/bin"
# Configure your LLM settings
git ai configBefore using Git AI, configure your LLM provider:
- Run git ai config
- Select your LLM provider (OpenAI, Anthropic, Ollama, or Other)
- Enter your API key
- Select your preferred model
- Customize the API endpoint if needed
Git AI checks configuration in these locations (highest to lowest precedence):
- Command-line config: git ai --config /path/to/config.yaml
- Project config: ./.git-ai.yamlin current directory
- User config: ~/.git-ai.yamlin home directory
- Environment variables:
- GIT_AI_API_KEY: LLM provider API key
- GIT_AI_MODEL: Model name (e.g., "gpt-4-turbo")
- GIT_AI_API_URL: API endpoint URL
 
- Git config variables:
- git-ai.conventionalCommits: Use conventional format (true/false)
- git-ai.commitsWithDescriptions: Include detailed descriptions (true/false)
 
- Default values
This provides flexible configuration at global and project-specific levels.
# Stage your changes
git add .
# Generate commit message
git ai commit
# Auto-approve and commit
git ai commit --auto
# Include detailed description
git ai commit --with-descriptions
# Use conventional format (type(scope): description)
git ai commit --conventional
# Avoid conventional format
git ai commit --no-conventional
# Amend previous commit
git ai commit --amend
# Generate branch name
git ai branch "Add sorting feature to user list"
# Generate branch with auto-approval
git ai branch --auto "Fix authentication bug"
# Provide description with flag
git ai branch -d "Update documentation for API endpoints"
# Use specific config file
git ai --config /path/to/config.yaml commitGit AI analyzes your commit history to detect conventional commit format usage. When over 50% of recent commits follow the type(scope): description pattern, Git AI defaults to this style.
Override detection with --conventional or --no-conventional flags. Git AI saves your format and description preferences for future commits.
Set preferences directly with Git's config system:
# Set conventional commit format preference
git config git-ai.conventionalCommits true
# Set detailed descriptions preference
git config git-ai.commitsWithDescriptions trueGit AI analyzes your staged changes and commit history, then sends this data to your configured LLM to generate relevant commit messages. The prompt includes:
- Staged changes diff
- Changed files list
- Recent commit messages
- Instructions for message formatting
Git AI presents an interactive terminal UI to approve, edit, or cancel the proposed message.
- OpenAI (GPT-4, GPT-3.5)
- Anthropic (Claude)
- Ollama (local deployment)
- Custom providers via API endpoints
Git AI embeds prompt templates from text files into the binary at compile time. Edit files in pkg/llm/prompts/ before building:
- commit_system.txt: LLM instructions with sections for conventional vs. standard format
- commit_user.txt: User prompt template with placeholders for content
- branch_system.txt: LLM instructions for branch name generation
- branch_user.txt: User prompt template for branch creation
The prompt files use Go's template syntax:
- For commit prompts:
- {{if .UseConventional}}...{{else}}...{{end}}controls format instructions
- {{.Diff}},- {{.ChangedFiles}},- {{.RecentCommits}}insert content
 
- For branch prompts:
- {{.Request}},- {{.LocalBranches}},- {{.RemoteBranches}}insert content
 
Rebuild with go build after modifying prompts.