Skip to main content
Module 5 · Lesson 1 of 518/34 in the course~16 min
Module lessons (1/5)

Discarding working edits vs unstaging (git restore)

Lesson preview5 hands-on exercises readyGit & Modern Collaboration · Module 5 — Undoing Mistakes & Recovery

Separate unstaging Index snapshots from discarding local edits using git restore.

What you'll learn in this lesson

  • Unstage files accidentally added to the Staging Index via git restore --staged <path> without erasing disk edits.
  • Discard unwanted Working Tree modifications cleanly using git restore <path>.
  • Restore older historical versions directly from any commit using git restore -s <commit> <path>.

Overview

Back in legacy Git, both switching branches and throwing away file changes used git checkout — meaning a tiny typo could wipe hours of local code irreversibly.

Modern Git isolates file restoration inside git restore, targeting either the Staging Index (--staged), the Working Tree (default), or an explicit historical commit (-s):

Sections covered in this lesson

  1. 1Two Separate Buttons for Two Separate Trees
  2. 2Compare Safety Profiles Across Undo Tools
Pro Lesson · Module 5 — Undoing Mistakes & Recovery

Unlock "Discarding working edits vs unstaging (git restore)" and the full Git & Modern Collaboration curriculum

Separate unstaging Index snapshots from discarding local edits using git restore.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Git & Modern Collaboration plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.