Skip to content
rajin

32Capstone: disaster recovery and final assessment

capstone45–60 minHandbook pp. 69–70 Not started

Warm-up · from “Capstone: simulate team collaboration and conflicts”

Why fetch rather than force-push after rejection?

No notes: write what you remember, then check. Recalling before reading is what makes it stick.

The problem

Three mistakes happen: detached commits disappear, a completed rebase is wrong, and a staged-only file is overwritten. Diagnose each independently.

After this lesson you can

  • Select recovery evidence for each failure.

  • Preserve work before repair.

  • Verify recovered commits and bytes.

Key terms

Full glossary

Say what each term means, then open it to check.

  • Reflog · from lesson 28

    Local log of ref updates when enabled.

  • HEAD · from lesson 14

    Current symbolic branch reference or detached commit identity.

  • Commit · from lesson 7

    Object identifying a root tree, parent(s), metadata and message.

  • Blob · from lesson 5

    Object storing file contents without a filename.

Visual mental model

  1. Identify loss
  2. Preserve evidence
  3. Locate object
  4. Create rescue ref or file
  5. Verify

Build the mental model

Scenario A: check out a tag v1.0, make two detached commits, then switch back to main. Recover both commits by locating the last detached tip and creating patch-v1. Scenario B: rebase payments onto main, finish with incorrect behavior, and restore the exact pre-rebase payments state. Find and verify the old tip in the branch or HEAD reflog; preserve the bad tip with a backup branch before resetting the correct checked-out branch. Scenario C: stage a new algo.py and hard-reset HEAD. Find its surviving blob, inspect the bytes and restore into a new file.

SimulationScenario A: lost detached commits

A simplified model for building intuition. It does not read your sandbox; use the terminal for real behaviour.

Under the hood

For real recovery, stop destructive commands and make a copy before investigating. Record current status, ref IDs and reflog evidence. A branch protects committed history, not arbitrary uncommitted edits. The answer key includes a reproducible reference sequence for all three cases; recovery is contingent on the relevant objects still existing.

Common mistake · important nuance

Do not run gc, prune or reflog expiry in a damaged repository. Do not assume ORIG_HEAD or a particular reflog index is always correct.

Move between parts freely. Completion counts only what you verify and answer.