rebase-recovery
Skill1 starsChanged 3 months agoMITView on GitHub
Move a branch onto a base that has moved, without silently reverting what landed in the meantime, and recover the work if a reset or rebase already destroyed it. Use when rebasing onto a moved main, restacking a branch whose parent PR was squash-merged, or when the user says "my PR is reverting things I never touched", "I lost my changes after a rebase", "rebase this onto main", or "restack this branch".
In this repository5 other files it gives its agents.
- fleet-review-loopSkill
- handoff-briefSkill
- lucidSkill
- parallel-workspacesSkill
- visual-reviewSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
If the reverted change sits in a file you also edited legitimately, your changed-files list looks exactly as expected.
- Distinctive: line 54
If this conflicts, resolve the conflict.
- Very specific: line 59
When a stacked PR is squash-merged, the base gains one new commit whose content matches your work but whose identity does not.
- Very specific: line 64
Use --onto with the recorded fork point of the *child* branch, or branch fresh from the base and reapply only the child's own changes.
- Distinctive: line 69
After any history surgery:
- Distinctive: line 75
Read the hunks, not just the file list.
- Distinctive: line 99
If you only want the file contents, take a path-scoped patch instead:
- Very specific: line 107
Use git apply -3, not git apply.
≈ “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
Rebase recovery
Rebasing is safe. The damage comes from reaching for git reset --soft when a
rebase conflicts, which trades a conflict you can see for a revert you cannot.
The trap
git reset --soft <base> moves the branch pointer and leaves your working tree
alone. The commit you make next therefore pairs the tree you already had with
the new base as its parent. Git records that as a change, so everything that
landed on the base since you branched is reverted inside your commit.
git reset --soft origin/main # branch pointer moves, tree does not
git commit -m "rebased" # this commit now reverts everyone else's workNothing warns you, and a rebase would have raised a conflict on the same content.
Why review misses it
If the reverted change sits in a file you also edited legitimately, your changed-files list looks exactly as expected. One file, the file you meant to touch. The revert is a hunk inside it:
-THEIR SECURITY FIX
+line1
line2
line3
+MY FEATUREScanning file names does not catch this. Only reading hunks does.
Move a branch correctly
Replay your commits onto the new base and name the old base explicitly:
git rebase --onto <new-base> <old-base> <branch><old-base> is where your branch forked. git merge-base <branch> <new-base>
finds it, but only while the base still contains that commit. Record the fork
point before you start, because a squash merge or a force push can remove it.
If this conflicts, resolve the conflict. A conflict means two changes touch the same lines, which is information. Do not switch to a reset to make it quiet.
Squash-merged parents
When a stacked PR is squash-merged, the base gains one new commit whose content
matches your work but whose identity does not. Git cannot tell your commits are
already in, so a plain git rebase <base> replays them and conflicts against
the squashed version.
Use --onto with the recorded fork point of the child branch, or branch fresh
from the base and reapply only the child's own changes.
Check before you push
After any history surgery:
git diff <base>...HEADRead the hunks, not just the file list. Every deletion should be a line you wrote. A deletion you do not recognize is someone else's work being reverted.
git range-diff <old-base>..<old-tip> <base>..HEAD shows how your commits
changed shape. Commits that fail to pair up mean the rewrite did more than move
them.
Recover work you already destroyed
The old tip is still in the reflog. Nothing is lost until the reflog expires.
git reflog <branch> # find the tip from before the surgery
PRE=<that sha>
OLD=$(git merge-base $PRE <base>)Then replay the original commits, which keeps their messages and authorship:
git checkout -B recovered $PRE
git rebase --onto <base> $OLD recoveredIf you only want the file contents, take a path-scoped patch instead:
git diff $OLD $PRE -- <your paths> > /tmp/mine.patch
git checkout -b recovered <base>
git apply -3 /tmp/mine.patchUse git apply -3, not git apply. Once the base has moved, the patch context
lines no longer match and a plain apply fails with patch does not apply. The
-3 flag falls back to a three-way merge using the blob index and succeeds.
Report what you did
Say which commits you replayed, what the fork point was, and what the diff against the base contains now. If you recovered from a destroyed branch, say that the old tip is still in the reflog and give its sha, so the user can check your work rather than trust it.
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.

