git-cli
A CLI tool that translates natural-language task descriptions into git commands using a local Ollama LLM.
Works in any terminal — including IntelliJ, Cursor, VS Code, and others.
Common tasks like "undo last commit" or "stash changes" are matched instantly without calling the LLM at all.
Prerequisites
# Install Ollama, then pull a fast model
Installation
Usage
# Describe what you want to do — git-cli prints the commands
# Add --execute (-x) to run the commands immediately
# Override the model for a single invocation
# Show the full prompt sent to the LLM
# See all example tasks
Instant Shortcuts
~30 common tasks are recognized by keyword and return instantly — no LLM needed:
Anything not matched falls through to the LLM for a full answer.
Safety
Destructive commands (push --force, reset --hard, clean -f, branch -D) are highlighted in red and blocked from execution unless you pass --force:
Commands containing shell injection patterns (&&, |, ;, $()) are always blocked.
Configuration
Persist defaults in ~/.git-cli.toml:
# View current settings
# Set the default model
# Set a custom Ollama endpoint
CLI flags (--model, --endpoint) override the config file.
Aliases
Define shortcuts in ~/.git-cli.toml to save typing:
[]
= "undo my last commit but keep changes"
= "squash last 3 commits"
= "push and set upstream"
Then run git-cli undo instead of the full description.
Shell Completions
Generate completions for your shell:
# Bash
# Zsh
# Fish
How It Works
- Checks for an alias match in your config.
- Checks for an instant shortcut match (~30 common tasks).
- If no match, gathers context from the current git repo (branch, status, recent log, remotes).
- Builds a prompt combining the context with your task description.
- Sends the prompt to the local Ollama API (with optimized parameters for speed).
- Parses and validates the response, stripping markdown artifacts.
- Displays the git commands with syntax highlighting.
- With
--execute, runs each command sequentially.
License
MIT