The brief
Engineer rebases a 6-commit feature branch onto updated main, force-pushes with --force, then discovers two dropped commits and a rewritten teammate commit — shared branch, colleagues already pulled.
Starter state (seed script)
mkdir rebase-recovery && cd rebase-recovery
git init && git switch -c main
echo "base" > shared.txt && git add . && git commit -m "main base"
git switch -c feature/analytics
for i in 1 2 3 4 5 6; do echo "feat $i" >> feature.txt; git add . && git commit -m "feat $i"; done
git switch main && echo "main update" >> shared.txt && git commit -am "main update"
git switch feature/analytics
git rebase main --force-rebase # the bad rebase
git push --force origin feature/analytics # to a local bare "remote"
Your task
- Diagnose what the rebase destroyed:
git reflog+git reflog feature/analytics+ORIG_HEAD— identify the dropped/rewritten commits. - Restore the branch to its pre-rebase state:
git reset --hard <pre-rebase-sha>(from reflog), verifygit diffagainst the original. - Repair the remote ref with
--force-with-leaseand explain lease semantics. - Write
POSTMORTEM.md: what--forcedestroyed, the recovery path, why--force-with-lease+ branch-per-author prevents recurrence.
Deliverables
- Repo URL with recovered branch (submission notes).
POSTMORTEM.md+ terminal transcript upload.
Submission contract: paste the repo URL into submission notes and upload POSTMORTEM.md + transcript. Reviewer checks the branch is restored to pre-rebase state and the remote ref was repaired with --force-with-lease.
100-pt rubric
- Diagnose dropped/rewritten commits via reflog + ORIG_HEAD (25)
- Restore branch to pre-rebase state, verify diff (25)
- Repair remote with
--force-with-lease, explain lease semantics (20) - POSTMORTEM distinguishes rebase vs merge conflict recovery (15)
- Prevention checklist (15)