A CLI tool that translates natural-language task descriptions into git (and GitHub CLI) commands using a local Ollama LLM.
Works in any terminal — IntelliJ, Cursor, VS Code, and others.
- Dual model routing — simple tasks use a fast small model, complex tasks auto-switch to a smarter model
- GitHub CLI support — generates
ghcommands for PRs, merges, and repo operations - Safety checks — destructive commands are blocked unless
--forceis passed; shell injection is always blocked - Smart parsing — handles multi-line LLM output, strips markdown, auto-fixes case/esac glob patterns
- Ollama running locally with models pulled
# Pull the default models
ollama pull qwen2.5:3b# From crates.io
cargo install git-cli
# From source
cargo install --path .# Describe what you want — git-cli prints the commands
git-cli "undo my last commit but keep the changes"
# Add --execute (-x) to run the commands immediately
git-cli "show status" --execute
# Use --force for destructive commands
git-cli "force push to origin" --execute --force
# Override the model for a single invocation
git-cli "create a branch called feature/auth" --model mistral
# Show the full prompt sent to the LLM
git-cli "rebase onto main" --verbose
# See all example tasks
git-cli examplesTasks are automatically classified as simple or complex:
# Simple tasks → fast model (qwen2.5:3b)
git-cli "show status"
git-cli "create branch feature/auth"
git-cli "stage all changes"
# Complex tasks → smart model (auto-detected)
git-cli "rewrite all commit messages to use conventional format"
git-cli "cherry-pick commit abc123 onto this branch"
git-cli "squash last 3 commits"The output shows which model was selected:
● Asking qwen2.5:3b (simple → fast model) for git commands...
● Asking qwen2.5:3b (complex → smart model) for git commands...
git-cli can also generate gh commands for GitHub operations:
git-cli "create a PR from this branch to main" --execute
git-cli "merge PR #3 and delete the branch" --execute
git-cli "list open pull requests" --executeDestructive commands (push --force, reset --hard, clean -f, branch -D, filter-branch) are highlighted in red and blocked unless you pass --force:
git-cli "force push to origin" --execute # blocked
git-cli "force push to origin" --execute --force # allowedCommands containing shell injection patterns (&&, |, ;, $()) outside of quoted strings are always blocked.
Settings are stored in ~/.git-cli.toml:
# View current settings
git-cli config
# Set a custom Ollama endpoint
git-cli config --endpoint http://myserver:11434Example ~/.git-cli.toml:
model_fast = "qwen2.5:3b"
model_smart = "qwen2.5:3b"
endpoint = "http://localhost:11434"
keep_alive = "10m"
[aliases]
undo = "undo my last commit but keep changes"
pub = "push and set upstream"CLI flags (--model, --endpoint) override the config file. --model overrides both fast and smart for that invocation.
Define shortcuts in ~/.git-cli.toml to save typing:
[aliases]
undo = "undo my last commit but keep changes"
squash3 = "squash last 3 commits"
pub = "push and set upstream"Then run git-cli undo instead of the full description.
# Bash
git-cli completions bash > ~/.bash_completions/git-cli
source ~/.bash_completions/git-cli
# Zsh
git-cli completions zsh > ~/.zfunc/_git-cli
# Fish
git-cli completions fish > ~/.config/fish/completions/git-cli.fish- Checks for an alias match in your config.
- Gathers context from the current git repo (branch, status, recent log, remotes).
- Classifies the task as simple or complex and selects the appropriate model.
- Builds a system prompt with rules and few-shot examples, plus a user prompt with repo context.
- Sends the prompt to the local Ollama chat API.
- Parses the response: joins multi-line commands, strips markdown, auto-fixes case/esac globs.
- Validates commands: blocks injection, checks HEAD~N against actual commit count, flags destructive ops.
- Displays commands with syntax highlighting.
- With
--execute, runs each command sequentially.
MIT