Skip to content

Choose a safe way to undo a change

≈ 10 minutesBeginner4 steps · 10 min estimated

Outcome. Pick between `restore`, `reset` and `revert` from where the change is and whether anyone else has it — and preview what each would discard.

Before you start: Understand what enters your next commit

The duration is an estimate of engaged work, not a timer — nothing here waits. Steps marked "Check" and "Practice" are verified in the browser; "Read" and "Lab" steps are yours to confirm.

  1. Read

    The decision, first

    ≈ 3 min

    Read the decision table and the `git reset` section that follows the revert one. The question to carry away: has anyone else got this commit?

  2. Predict

    Predict: which command?

    ≈ 1 min

    One situation, one command.

    A commit you pushed an hour ago broke the build and two colleagues have already pulled it. Which command undoes it without rewriting their history?
    Why

    `revert` adds a new commit containing the inverse change; history is appended to, never rewritten, so nobody diverges. `reset` and `amend` rewrite; `restore` only touches files that are not committed.

  3. In Practice Mode do "Discard an unstaged edit" first, then "Undo a commit that is already shared". The second one is what completes this step.

    Scenario: Undo a commit that is already shared — completes automatically when the simulator's check passes.

  4. Check

    Knowledge check: HEAD and reset

    ≈ 1 min

    HEAD is what `reset` moves; this check makes sure the model is in place.

    Completes when the knowledge check on that page has been attempted.

When you are done: Recover a deleted branch. The reflog you glimpsed in reset is the tool for the next recovery, and it is a 20-minute session.

How did this go?