Git Rescue
Collects local Git recovery evidence and prepares a reviewable plan without running recovery commands.
- Input
- A local Git repository selected by the user
- Output
- A JSON snapshot and proposed command plan for a person to review and run separately if appropriate.
What it does
- Reports repository state, conflicts, operation, and local tracking divergence
- Surfaces reflog candidates as evidence, not proof of lost work
- Never resets, checks out, stashes, fetches, or executes a recovery plan
Overview
Git Rescue is a read-only Python 3.11+ diagnostic CLI that inspects broken or confusing local Git states—such as detached HEADs, merge conflicts, and reflog candidates—and emits structured JSON recommendations. It never runs mutating Git commands like reset, checkout, merge, rebase, stash, or fetch, leaving every recovery action strictly under human control.
When to use it
- Diagnosing a detached HEAD, interrupted rebase, or conflicted working tree without risking accidental history loss.
- Giving coding agents a safe, read-only Git inspection step that cannot mutate branches or discard uncommitted work.
- Reviewing structured reflog candidates and suggested next commands before manually executing any Git recovery.
Diagnose a broken Git state
Needs Python 3.11 or newer, the standard library and a local Git install. Run from the package directory and pass it the repository directory.
python3 scripts/git_rescue.py /path/to/repositorySample output
Abridged output from the 0.1.0 package, run on a temporary repository with a detached HEAD.
{
"status": "ok",
"detached": true,
"branch": null,
"conflicts": [],
"recommendations": [
"HEAD is detached. Review its commit and reflog candidates before deciding whether to create a rescue branch."
],
"actions_executed": []
}Exit codes and limits
- Git inspection is read-only: no fetch, reset, merge, rebase, stash or checkout is run.
- Suggested next commands are listed with executed set to false; you decide whether to run them.
- Reflog candidates do not prove lost work, upstream refs may be stale, and paths in the report may be sensitive.
Questions
Will Git Rescue modify my branches, working tree, or commit history?
No. Git Rescue is strictly read-only. It never runs fetch, reset, merge, rebase, stash, or checkout, and always reports actions_executed as empty.
How does it suggest recovery steps safely?
Every suggested next command is returned in the JSON report with executed set to false so you can inspect the diagnosis and decide which commands to run yourself.
What dependencies does Git Rescue require?
Python 3.11 or newer (standard library only) and a local Git installation.
Can I share the JSON report publicly without redacting it?
Be careful: repository file paths and reflog references in the diagnostic report may be sensitive, and upstream refs may be stale since no network fetch is performed.