- Home
- Skills
- Testing & Debugging
- Rescue Recipes for Git™: Undo Resets and Force-Pushes Safely
Works with the AI Agents you already use
Rescue Recipes for Git™: Undo Resets and Force-Pushes Safely
Finds lost commits after an accidental reset, amend, rebase, branch delete, dropped stash, bad merge or force-push, and writes a rescue that starts with a backup branch and changes nothing until you agree.
$5
Rescue Recipes for Git™: Undo Resets and Force-Pushes Safely
Example session with this skill installed
I ran git reset --hard HEAD~2 by accident and my last two commits are gone. Can I get them back?
- Read your context and instructions
- Compiled the rescue recipes
Summary
The last HEAD move was a reset, and both commits are still in the reflog. This is the real script output on the bundled demo repository.
- HEAD:
6d46a73ff718on branchfeature/discounts - Working folder: 0 staged, 0 changed, 0 untracked
Last HEAD moves (newest first):
6d46a73ff718HEAD@{0}:reset: moving to HEAD~26b4b4390bdf5HEAD@{1}:commit: test(discount): cover the 10 percent case4d1c8ca31483HEAD@{2}:commit: feat(discount): add percentage discounts
Situation that matches: undo-last-move (the last HEAD move was a reset).
Recipe
Step 1: Back up, and restore the state from before the reset as a new branch to look at. The block first checks that HEAD and the branch are where the capture saw them, makes a backup branch rescue/<time>, then creates rescued/<time>-6b4b439 at the lost commit and shows its log. Nothing else changes.
Step 2: Only after you agree: move feature/discounts back to that state with git reset --keep, which stops instead of overwriting files with local changes. It makes another backup branch first.
Step 3: Check
git log -3 --format='%h %ci' &&
git branch --list 'rescue/*' 'rescued/*'
Each block runs as one command and stops at its first failure. Nothing is pushed.
Connects securely to your tools. The creator never sees your data.
About this skill
Use when something went wrong in a repository and you want the work back without making it worse.
A standard-library Python script reads a capture of git's own reflog, status, stash list, branches and upstream, shows what it sees and suggests which of seven situations matches: a commit to undo, a reset, amend or rebase to undo, a dropped stash, commits on the wrong branch, a deleted branch, a bad merge, or a force-push that removed commits from a shared branch.
For the situation you confirm, it prints a recipe as short command blocks. Every block that changes something first checks that HEAD and the current branch are still where the capture saw them and makes a backup branch; the lost work is restored as a new branch you can look at, and only then is the step that moves a branch offered, using git's reset --keep, which stops instead of overwriting local changes; the block also stops first if an ignored file would be replaced. Nothing is pushed; when a shared branch needs fixing, the push stays your own step.
Commit subjects, branch names and stash messages that contain a credential in a common format (cloud, code-hosting and API keys, tokens, private keys, passwords in URLs or in NAME=value form) are withheld from the script's output, and the recipe's own commands print commit ids and dates rather than subjects. Changes that were never committed or stashed usually cannot be recovered by git, and the skill says so.
Do not use when you want to plan new commits, resolve a normal merge conflict or remove a pushed secret from history.
Example prompts
- "I ran git reset --hard and my last two commits are gone. Can I get them back?"
- "I dropped a stash by accident."
- "Someone force-pushed to our feature branch and my commits disappeared."
Independent
Not affiliated with or endorsed by the Git project, Software Freedom Conservancy, Anthropic, OpenAI, Anysphere (Cursor) or Google. Git and the Git logo are either registered trademarks or trademarks of Software Freedom Conservancy, Inc., corporate home of the Git Project, in the United States and/or other countries. Other product names are used only to describe compatibility.
The script suggests from what git recorded; you confirm what happened. Lost commits stay findable through the reflog until its entries expire: by git's documented defaults after 90 days, or 30 days for entries no longer reachable from the branch tip. A dropped stash has no reflog entry; git gc can prune it once the object is two weeks old (gc.pruneExpire), counted from when the stash was made. Only the latest HEAD move is suggested; a pushed fast-forward merge gets an explanation, not a recipe; stopping a merge in progress discards conflicts already resolved. Credentials in other formats, or written as prose, are not recognised. A force-push by someone else is only visible if you fetched the branch before and after it.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 9 days ago
Requires