A command-line assistant that makes git usable: predict problems, suggest safe fixes, and explain what is going on in plain English. Binary: sg.
Every command prints the same four-part structure—summary, risk, recommendation, and optional detail—so you can scan output quickly or pipe it to tooling.
sg status summarizes branch position, working tree, and what to do next without reading raw git porcelain.
sg commit builds a commit plan from staged changes and asks before writing. Requires a configured provider.
sg explain turns diffs into plain-language intent and next steps. Requires a configured provider.
sg push evaluates divergence, conflicts, and hosted signals before you publish.
sg check scores integration risk against your target branch—not generic “commit linting.”
sg fix walks common failure modes (conflicts, detached HEAD, interrupted rebase) with safe, confirmable steps.
sg wtf runs urgent checks. Add --learn to record fault signals or --fix-ci for CI-focused remediation hints.
sg sync, sg ship / sg ship --status, sg split, and sg time-travel --to … cover sync, ship pipelines, splitting commits, and safe navigation—including natural-language refs.
sg who (optional --file for a file or directory), sg queue --team, and sg blame --file … --line … --explain add hosted and local context.
sg doctor reports repository health signals; sg pair --action … supports lightweight pair handoffs.
OpenAI, Anthropic, Google (Gemini), Mistral, or a custom HTTP endpoint via sg ai-configure (use --url for custom bases).
When AI is missing or unreachable, commands that do not strictly need a model fall back to deterministic rules. AI-only commands exit with a clear message.
Install the sanegit package globally; invoke everything as sg <command>.
Core loop
sg status
Plain-English repository state and recommended next action.
sg explain
Explain current changes (requires AI).
sg commit
Proposed commit from staged files; confirms before git commit (requires AI).
sg push
Pre-push risk checks and safer publish flow.
sg check
Merge and integration readiness vs. a target branch.
Recovery & undo
sg fix
Guided recovery from common broken git states.
sg undo
List reversible rollbacks with explicit consequences.
sg wtf
Urgent diagnosis; --learn, --fix-ci.
Sync, ship, split
sg sync
Preserve local work while updating from mainline.
sg ship
One-command delivery; use sg ship --status for workflow state.
sg split
Propose logical commit groups from staged changes.
Team, hosting, history
sg who [--file <path>]
Ownership and collaborator context; path may be a file or directory.
sg queue --team
Merge queue visibility and risk hints.
sg blame --file <path> --line <n> --explain
Line history with rationale (hosted context when available).
sg time-travel --to <ref>
Resolve revisions safely, including natural-language references.
sg pair --action <start|status|handoff>
Pair sessions; use --session with status and handoff.
Diagnostics & AI setup
sg doctor
Deep repository health signals (HEAD, objects, working tree, etc.).
sg ai-configure
Set provider, --credential-ref, optional --url for custom APIs.
You can stay entirely in rule-based commands, add AI only where it helps, and use hosted features when gh or remotes are available.
sg status after switching branches or pulling.sg explain (with AI) or read diffs; use sg check before a big merge.sg commit when you want an AI-assisted message, or commit normally.sg push or your team’s sg ship flow; follow sg ship --status if delivery is multi-step.sg wtf first, then sg fix or sg undo as suggested.SaneGit is distributed as an npm package and runs on modern Node with git available on your PATH.
engines)gh) for richer hosted contextPer-repository settings live under .sanegit/. Treat that directory as local-only and add it to .gitignore.
openai, anthropic, google (Gemini), mistralcustom with --url pointing at your HTTP APIAPI keys are not written into config files. Pass a credential reference—typically an environment variable name—via --credential-ref so secrets resolve at runtime.
sg explain and sg commit need a working provider configuration. Other commands may still run with rules, hosted APIs, or local git data.
Inside any git repository:
Source, detailed guide, and package metadata:
SaneGit is MIT-licensed. Issues and contributions are welcome on GitHub.