gitgud is a Rust CLI that adds a terminal UI and guided Git recovery, commit, and push workflows on top of normal Git.
- Rescues wrong-branch commits, detached HEAD, bad rebases, lost stashes, accidental resets, and force-push mistakes
- Generates 1-3 commit message options from the staged diff
- Explains staged changes with intent, risks, and test ideas
- Captures commit-level Git memory with structured summaries, likely intent, feature labels, and related files
- Suggests exact Git commands from natural language requests
- Pushes the current branch with explicit confirmation before
--force-with-lease - Supports standard commits and Conventional Commits presets
- Uses Gemini by default, or any OpenAI-compatible API including Ollama
Latest release:
curl -fsSL https://raw.githubusercontent.com/denyherianto/gitgud/master/install.sh | shSpecific release:
curl -fsSL https://raw.githubusercontent.com/denyherianto/gitgud/master/install.sh | sh -s -- --version v0.1.0Requirements:
gitonPATH- Rust toolchain if building from source
- An API token for AI-backed features unless you use
heuristic-onlymode
Interactive setup:
gg config
gg doctorTypical usage:
gg version
gg rescue
gg ship
gg commit
gg explain
gg memory install
gg memory explain HEAD~1
gg memory search billing
gg memory impact src/app.rs
gg memory stale
gg push
gg ask "undo last commit but keep changes"
gg "unstage package.json"Build from source:
cargo run --bin gg -- --help
cargo run --bin gg -- config
cargo run --bin gg -- commit| Command | Description |
|---|---|
gg |
Open the home TUI with branch, staged/unstaged counts, and remote status |
gg version |
Print the installed gitgud version |
gg rescue [incident] |
Diagnose common Git mistakes, preview recovery steps, create a safety snapshot, and save rollback notes |
gg commit |
Generate commit options from staged changes and commit after confirmation |
gg ship |
Run one ship flow: preflight, commit cleanup suggestions, review draft generation, and push |
gg explain |
Explain the staged diff in four sections |
gg push |
Push the current branch and offer --force-with-lease only after confirmation |
gg ask <query> |
Turn a natural language Git request into exact command(s) with risk guidance |
gg config |
Open the interactive setup screen and install the Git-memory hook when you save inside a repo |
gg config show |
Print effective config values and their sources |
gg config set <key> <value> |
Persist one config value |
gg config unset <key> |
Remove one persisted config value |
gg auth login |
Store an API token in the system keychain |
gg auth status |
Show whether an API token is available and where it comes from |
gg auth logout |
Remove the stored API token from the keychain |
gg doctor |
Check Git, repo state, token availability, config resolution, and provider reachability |
gg learn |
Rebuild repo-specific memory and backfill commit-intelligence memory for the last 50 commits |
gg memory install |
Install or refresh the managed post-commit hook for commit-memory capture |
gg memory learn |
Backfill commit-intelligence memory for recent history |
gg memory explain <commit> |
Explain one commit from stored Git memory |
gg memory search <query> |
Search commit memory by feature, intent, file, or commit text |
gg memory impact <file> |
Show the features and commits most related to one file |
gg memory stale |
Report likely stale files from commit-memory history |
gg git <args> |
Pass a command straight to raw Git |
gg <git-subcommand> |
Unknown Git subcommands are passed through directly |
gg <natural language> |
Unrecognized input that is not a Git subcommand is routed to ask |
gitgud stores non-secret settings in a per-user config file and stores API_TOKEN in the system keychain.
Config precedence:
- Environment variables
- Global config file
- Built-in defaults
Environment overrides:
API_TOKENBASE_API_URLBASE_MODELAI_TIMEOUT_SECSdefault60
Interactive setup supports:
- provider:
geminioropenai-compatible BASE_API_URLBASE_MODELAPI_TOKEN- commit style:
standardorconventional - generation mode:
auto,ai-only, orheuristic-only - provider model loading from
/modelsafterBASE_API_URLandAPI_TOKENare set, sorted newest-first when the provider returns creation timestamps, with a scrollable picker for long lists
Use gg config show to print the exact config path and the source of each effective value.
OpenAI-compatible example:
gg config set provider openai-compatible
gg config set base-api-url https://api.openai.com/v1
gg config set base-model gpt-4.1-mini
gg auth login --token "$OPENAI_API_KEY"
gg doctorOne-off environment override:
export API_TOKEN="$OPENAI_API_KEY"
export BASE_API_URL="https://api.openai.com/v1"
export BASE_MODEL="gpt-4.1-mini"
gg commitNotes:
- the default provider is
gemini - when switching providers, set
provider,BASE_API_URL, andBASE_MODELtogether - environment
API_TOKENoverrides the keychain
Ollama works through its OpenAI-compatible API:
gg config set provider openai-compatible
gg config set base-api-url http://localhost:11434/v1
gg config set base-model llama3.1:8b
gg auth login --token ollama
gg doctorOr with environment variables:
export API_TOKEN="ollama"
export BASE_API_URL="http://localhost:11434/v1"
export BASE_MODEL="llama3.1:8b"
gg explainNotes:
API_TOKENmust be non-empty, even for local providers- keep Ollama running if you want the model picker to load
/models - if Ollama uses a different host or port, use that full
/v1base URL
gitgud can turn commit history into a local knowledge base:
- a managed
post-commithook runsgg memory ingest --commit HEADafter each commit - each analyzed commit stores structured metadata for
what_changed, likelywhy,feature, andrelated_files - commit-memory data is stored outside the repo under
~/.config/gitgud/repos/<repo-slug>/git-memory/ - the hook installer refuses to overwrite a
post-commithook it does not manage gg configinstalls the hook automatically when you save settings inside a Git repo, andgg memory installcan install it explicitlygg memory explain,search,impact, andstalequery the stored commit intelligencegg shipincludes recent Git-memory context in the review-planning flow, andgg commitreuses cached context when available- if no Git memory exists yet,
gg memorycommands andgg learnbackfill recent history on demand
auto: use the configured AI provider and fall back to heuristic suggestions on timeoutai-only: require the AI provider and surface provider errorsheuristic-only: skip the AI provider and generate local suggestions only
Built-in default types:
featfixrefactordocstestchoreperfbuildci
Custom preset example:
commit_style = "conventional"
generation_mode = "auto"
[conventional_commits]
preset = "team"
[conventional_commits.presets.team]
types = ["feature", "bugfix", "maintenance"]Select or clear a preset:
gg config set conventional-preset team
gg config unset conventional-presetgg rescueauto-detects likely recovery incidents, lets you override the incident, previews exact commands, creates a hidden snapshot ref, and saves rollback notes under.git/gitgud/rescue/- supported rescue incidents are
wrong-branch,detached-head,bad-rebase,lost-stash,accidental-reset, andforce-push - force-push rescue can restore from a detected commit or a manual SHA/ref fallback and only fetches remote refs after confirmation
gg commitandgg explainonly use staged changesgg commitwarns about risky staged diffs, supports inline editing, and creates one commit from the staged changesgg shipcan roll staged work into the existing commit flow first, surfaces split/squash cleanup suggestions for the outgoing branch, drafts a review title/body, and pushesgg askreturns recommended and alternative commands with risk badges and explanations- dangerous actions suggested by
gg askrequire extra confirmation before execution gg pushwarns about risky outgoing diffs and does not guess across ambiguous remotes- repo memory is built automatically on first use in any repo and refreshed every 7 days; it records commit style, conventional types/scopes, branch naming patterns, and frequently changed directories, then injects that context into every AI prompt — run
gg learnto force an immediate rebuild and backfill commit intelligence - repo memory is stored in
~/.config/gitgud/repos/(one TOML file per repo, never committed) - Git memory stores one JSON file per analyzed commit plus a JSON index under the same repo-specific config area
gitgudshells out to the systemgit, so hooks, credentials, and normal Git config still apply- detached HEAD is rejected for commit and push flows
Run checks:
cargo fmt
cargo testProject docs:
- Contributor guidance:
AGENTS.md - Contributing:
CONTRIBUTING.md - Code of conduct:
CODE_OF_CONDUCT.md - License:
LICENSE
