hermes

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.

context

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.

task

Help recover lost work.

What happened: Only if [GIT_OUTPUT] is given: Output so far:

  1. 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.
  2. Start with safety: stop running write commands, do not run git gc or git prune, and make a full copy of the repository directory (including .git) before changing anything.
  3. Give read-only commands to locate the work, explaining what each one shows:
  • git reflog and git reflog show <branch> for previous positions of HEAD and branches; ORIG_HEAD after a reset, rebase or merge;
  • git fsck --lost-found or git fsck --unreachable --no-reflogs for dangling commits and blobs, including dropped stashes (stash commits have messages starting "WIP on" or "On <branch>"); list them readably with git fsck --unreachable --no-reflogs | grep commit | cut -d' ' -f3 | xargs git log --no-walk --format='%h %ci %s';
  • git show <sha> and git 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.
  1. 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.
  2. Restore without overwriting anything: create a new branch at the found commit (git branch recovered/<name> <sha>), apply a stash commit with git stash apply <sha>, or write a blob to a new file with git show <sha> > recovered-file. Only then compare and merge into the working branch.
  3. 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.
  4. 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.
constraints
  • 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 gc or git prune during 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.
output format

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

Edit on GitHubReport a problem

use in

Hodios CLI
npx @hermes-hq/hodios install recover-lost-git-work --target claude-code
Agent Skills
npx skills add hermes-hq/hodios-dist --skill recover-lost-git-work -a claude-code
Add the Hodios marketplace (once)
claude plugin marketplace add hermes-hq/hodios-dist
Install the software-engineering plugin
claude plugin install hodios-software-engineering@hodios

The plugin brings every entry in this domain at once.

more in git and version control

All of Git and version control
PromptGit and version control

Resolve 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-conflict
PromptGit and version control

Write 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-message
PromptGit and version control

Write 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-description
PromptGit and version control

Choose 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-strategy
PromptGit and version control

Clean 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-history
RuleGit and version control

Conventional 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