git-recovery
Skill1 starsChanged 9 months agoMITView on GitHub
Recovers from git disasters - force-pushed over work, broken rebase, detached HEAD, lost commits, bad merges, and accidentally deleted branches. Use when git state is broken and you need to recover work without making things worse.
- Deletes or force-pushes
- Commits and pushes
3 other projects use a version of this.
Adopted by
Most recently taken up by
- dagarre00/claude-code-templatetheir own version, first seen Sep 7, 2026
- gabrielbauman/skillstheir own version, first seen Jul 16, 2026
- DaleSeo/git-skillstheir own version, first seen Jan 26, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- dagarre00/claude-code-template★ 1same name
- DaleSeo/git-skills★ 1same name
- gabrielbauman/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository48 other files it gives its agents.
- accessibilitySkill
- api-designSkill
- api-integrationSkill
- architectSkill
- async-patternsSkill
- best-practicesSkill
- bugSkill
- buildSkill
- cachingSkill
- ci-cdSkill
- config-managementSkill
- containerizeSkill
- database-designSkill
- data-modelingSkill
- data-pipelineSkill
- debug-latencySkill
- dependency-updateSkill
- deploySkill
- dev-setupSkill
- docsSkill
- error-handlingSkill
- estimateSkill
- feature-flag-opsSkill
- i18nSkill
- iacSkill
- incidentSkill
- load-testingSkill
- loggingSkill
- migrateSkill
- monitoringSkill
- observability-debugSkill
- onboardSkill
- perfSkill
- phase-gateSkill
- pr-authorSkill
- qaSkill
- refactorSkill
- reviewSkill
- rollbackSkill
- schema-evolutionSkill
- scope-checkSkill
- security-auditSkill
- state-managementSkill
- tech-debtSkill
- tech-stackSkill
- telemetrySkill
- testingSkill
- workflowSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Stop. Don't run another command until you've diagnosed the situation.
- Distinctive: line 20
Every entry is a commit SHA you can recover.
- Distinctive: line 37
If someone else already pulled the bad state, coordinate with them before force pushing again.
- Distinctive: line 185
Before running any of these: git stash your uncommitted work, and note the current SHA from git log --oneline -1.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Git Recovery
Stop. Don't run another command until you've diagnosed the situation. Most git "disasters" are fully recoverable if you don't make them worse.
First: Check the Reflog
The reflog records every HEAD movement for the last 90 days. Even "deleted" commits are still there.
git reflog # See recent HEAD positions
git reflog show main # See recent main branch positions
git reflog show --all # All branchesEvery entry is a commit SHA you can recover. The reflog is your safety net.
Common Disasters
"I force-pushed and lost commits on remote"
# 1. Find the commit before the force push in reflog
git reflog
# 2. The old HEAD is still there. Reset to it.
git reset --hard <old-sha>
# 3. Force push the recovered state
git push --force-with-lease origin branch-nameIf someone else already pulled the bad state, coordinate with them before force pushing again.
"I'm in detached HEAD state"
# You're not on a branch. Your commits are floating.
# If you have commits to save:
git branch recover-branch # Create a branch at current position
git checkout main # Go back to a real branch
git merge recover-branch # Merge your work in
# If you just checked out a tag/SHA by accident:
git checkout main # Just go back to your branch"I rebased and everything is broken"
# 1. Find the pre-rebase state in reflog
git reflog
# 2. Look for the entry BEFORE the rebase started (e.g., "rebase started")
# It will look like: abc1234 HEAD@{5}: checkout: moving from feature to main
# 3. Reset to the pre-rebase state
git reset --hard <pre-rebase-sha>During a rebase that's going badly:
git rebase --abort # Undo the entire rebase, go back to before"I committed to the wrong branch"
# Committed to main when you meant to commit to feature-branch
# 1. Note the commit SHA
git log --oneline -3
# 2. Create/switch to the right branch with the commit
git branch feature-branch # Branch now has the commit too
# or if branch exists:
git checkout feature-branch
git cherry-pick <sha>
# 3. Remove the commit from the wrong branch
git checkout main
git reset --hard HEAD~1 # Remove last commit from main"I accidentally deleted a branch"
# 1. Find the branch tip in reflog
git reflog | grep "branch-name"
# or
git reflog --all | grep "branch-name"
# 2. Recreate the branch at that commit
git branch branch-name <sha>"I ran git reset --hard and lost uncommitted work"
If the files were ever staged (git add):
# Staged files are stored as blobs
git fsck --lost-found
# Look in .git/lost-found/other/ for your filesIf the files were never staged: They're gone. This is the one truly unrecoverable git scenario. This is why you commit early and often.
"Merge conflict and I don't know what to do"
# See what's conflicted
git status
# For each conflicted file, edit and resolve the markers:
# <<<<<<< HEAD
# your changes
# =======
# their changes
# >>>>>>> branch-name
# After resolving:
git add resolved-file.txt
git commit # Complete the merge
# If you want to abort the entire merge:
git merge --abort"I need to undo the last commit but keep the changes"
git reset --soft HEAD~1 # Undo commit, keep changes staged
git reset HEAD~1 # Undo commit, keep changes unstaged
git reset --hard HEAD~1 # Undo commit AND discard changes (careful!)"I need to undo a commit that's already pushed"
# Create a NEW commit that reverses the bad one (safe for shared branches)
git revert <sha>
git push
# NEVER use reset + force push on shared branches unless coordinating with the teamRecovery Decision Tree
Is the commit in the reflog?
YES → git reset --hard <sha> or git cherry-pick <sha>
NO → Was it ever staged?
YES → git fsck --lost-found
NO → Was it ever committed?
YES → Check reflog again (git reflog --all)
NO → The work is gone. Sorry.Prevention
| Practice | Prevents |
| Commit early, commit often | Losing unstaged work |
--force-with-lease not --force | Overwriting others' pushed commits |
| Branch protection rules | Accidental force push to main |
git stash before risky operations | Losing uncommitted work during rebase/reset |
| Don't rewrite shared history | Confusion and lost work across the team |
Dangerous Commands (Require Caution)
git reset --hard # Discards uncommitted changes permanently
git push --force # Overwrites remote history (use --force-with-lease)
git clean -fd # Deletes untracked files permanently
git checkout -- . # Discards all unstaged changes
git rebase -i # Rewrites history (can lose commits if done wrong)Before running any of these: git stash your uncommitted work, and note the current SHA from git log --oneline -1.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

