Recover lost Git work
Recovers commits, branches, stashes and staged files lost to a reset, rebase or dropped stash, using reflog and fsck after a backup, explaining each command. Use right after a git mistake.
Git rarely deletes committed work immediately. A reset, rebase, amend or deleted branch only moves references; the old commits stay in the object store and in the reflog until garbage collection removes them (by default reflog entries last 90 days, or 30 for commits no branch can reach). A dropped stash is a dangling commit. Staged but uncommitted files exist as blobs. Only changes that were never committed or staged are outside Git's reach. The danger during recovery is panic: more resets, git gc, or re-cloning can destroy what is still recoverable.
Help recover lost work.
What happened: Only if [GIT_OUTPUT] is given: Output so far:
- Classify the loss: commits lost by reset, rebase or amend; a deleted branch; a dropped or cleared stash; staged files lost by reset or checkout; uncommitted, unstaged changes overwritten; a force-pushed remote branch; or something else. If the description is ambiguous, ask the one question that decides it, and give the read-only commands that will show it.
- Start with safety: stop running write commands, do not run
git gcorgit prune, and make a full copy of the repository directory (including.git) before changing anything. - Give read-only commands to locate the work, explaining what each one shows:
git reflogandgit reflog show <branch>for previous positions of HEAD and branches;ORIG_HEADafter a reset, rebase or merge;git fsck --lost-foundorgit fsck --unreachable --no-reflogsfor dangling commits and blobs, including dropped stashes (stash commits have messages starting "WIP on" or "On <branch>"); list them readably withgit fsck --unreachable --no-reflogs | grep commit | cut -d' ' -f3 | xargs git log --no-walk --format='%h %ci %s';git show <sha>andgit log -p <sha>to confirm a candidate is the lost work. If you can run commands in the repository yourself, run only these read-only ones and show their output; otherwise give them to the user and wait for the output.
- List the candidates with sha, date, subject and a
git show --stat <sha>summary so the user can recognise their work, ranked by how well each matches the description. - Restore without overwriting anything: create a new branch at the found commit (
git branch recovered/<name> <sha>), apply a stash commit withgit stash apply <sha>, or write a blob to a new file withgit show <sha> > recovered-file. Only then compare and merge into the working branch. - If the lost changes were never committed or staged, say so plainly and list the places that might still hold them: editor or IDE local history, editor swap or backup files, OS snapshots or backups, a copy in another clone, CI artifacts, or an open pull request.
- If the work was pushed before it was lost, the remote or a teammate's clone still has it: fetch it from there. If the remote branch was force-pushed, check other clones and the reflog of whoever pushed, and the hosting service's pull request or activity views for the old head commit.
- Every command you give is read-only until the user has a backup. Label each command read-only or writes.
- Never suggest
git reset --hard,git checkout -- .,git clean,git gcorgit pruneduring recovery. - Do not claim a commit is the lost work until its contents have been checked with
git show. - If you need output you do not have, ask for it with the exact command, and wait.
- Separate what you verified from what you inferred. Mark inferences as such.
- When you do not know, say "I don't know" once and state what would settle it.
What likely happened
Two or three sentences, and the one question to ask if unsure.
Stop and back up
The backup command for the user's platform.
Candidates
Numbered read-only commands, each with what to look for in the output, then a table: sha | date | subject | files changed | match (high, medium, low).
Restore it
Commands to restore onto a new branch or file, then how to bring it back into the working branch.
If it is not there
Where else the work may survive, in order of likelihood.
1 required value still a placeholder; the assistant will ask for it.
details
- kind
- Prompt: a task you run by name to get one finished thing back
- domain
- Software engineering
- category
- Git and version control
- level
- Intermediate
- made for
- Software engineer
- risk
- read-only
- version
- v1.1.0 · experimental
- reviewed
- 2026-10-02
- aliases
- recover-lost-work
- works in
- Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md, ChatGPT, claude.ai
use in
npx @hermes-hq/hodios install recover-lost-git-work --target claude-codenpx skills add hermes-hq/hodios-dist --skill recover-lost-git-work -a claude-codeclaude plugin marketplace add hermes-hq/hodios-distclaude plugin install hodios-software-engineering@hodiosThe plugin brings every entry in this domain at once.
more in git and version control
All of Git and version controlResolve a merge conflict
Resolves merge, rebase or cherry-pick conflicts by reading both sides and their common base, keeps the intent of each, and asks when the intents contradict. Use when git stops on a conflict.
resolve-merge-conflictWrite a commit message
Writes a commit message that states what changed and why, in the repo's own convention, and flags staged changes that should be split. Use before committing.
write-commit-messageWrite a pull request description
Writes a pull request description that tells reviewers why the change exists, what to look at first, how to test it and what could break. Use when opening a PR.
write-pr-descriptionChoose a branching strategy
Recommends a branching and release strategy such as trunk-based, GitHub flow or release branches for a team's size, cadence and environments, with rules, protections and migration steps.
choose-branching-strategyClean up a branch's commit history
Plans an interactive rebase that turns a messy branch into logical, reviewable commits, with a backup, the exact todo list and a check that the code is unchanged. Use before merging a WIP branch.
clean-up-commit-historyConventional Commits rules
Makes the assistant write every commit in Conventional Commits 1.0.0 format, one logical change per commit, with honest breaking-change footers. Use in repos that release from commits.
conventional-commits-rules