The brief
On-call engineer checks out a release tag to reproduce a stakeholder's number, makes a "quick fix" commit while detached, then git switch main — the fix vanishes from all branches the night before a reporting deadline.
Starter state (seed script)
mkdir rescue-drill && cd rescue-drill
git init && git switch -c main
for i in 1 2 3 4 5; do echo "v$i" >> report.py; git add . && git commit -m "report v$i"; done
git tag v1.2
git checkout v1.2 # DETACHED HEAD
echo "fix off-by-one in totals" >> report.py
git add . && git commit -m "fix off-by-one in totals" # orphan commit
git switch main # the fix "vanishes"
Your task
- Confirm the fix is gone from every branch:
git log --all --onelineshows nofix off-by-one. - Find the orphan commit:
git reflog→ locate thecommit: fix off-by-one in totalsentry → note its SHA. - Recreate the branch at that SHA:
git switch -c fix/off-by-one <sha>. - Verify the content:
git log --oneline --graphshows the rescued commit on a named branch;cat report.pycontains the fix. - Write
RESCUE.md: what detached HEAD means, how reflog located the orphan, the prevention rule (never commit detached; usegit switch -c).
Deliverables
- Repo URL (submission notes).
RESCUE.mdfile upload.
Submission contract: paste the repo URL into submission notes and upload RESCUE.md. Reviewer checks the rescued branch exists with the fix content, and the graph shows a clean topology.
100-pt rubric
- Reproduce detachment + locate orphan via reflog (25)
- Recreate branch at orphan SHA, verify content (25)
- Explain detached-HEAD semantics correctly in RESCUE.md (20)
- Graph shows clean topology (15)
- Prevention rule stated (15)