ch08 · operator · 85-115 min

Git for Linux operators

Use Git as a working-tree safety system: inspect, stage, branch, sync, recover.

You can preserve work and recover local history without making a repository worse.

gitstatusreflogrebasestash
Teaching diagramch08 · mental model
Where your work lives working tree edited files index staged commit / branch local history remote origin add -p commit push pull --ff-only git reflog local log of every HEAD move, even after reset save point before repair: backup branch / stash reset --hard discards work never a reflex

shows: The states work passes through (working tree, index, commit/branch, remote), the commands that move it between them, and reflog as the local-only save-point net that reset --hard can otherwise destroy.

does not prove: It does not prove your repository is recoverable: reflog only protects commits Git has actually recorded, so unstaged or untracked working-tree changes wiped by reset --hard are not in scope and stay gone.

Lessons in this chapter

  1. ch08/l01 Working tree, index, commit git status Know exactly where a change is before committing or switching context.
  2. ch08/l02 Branch and remote sync git pull --ff-only Sync without surprising history changes.
  3. ch08/l03 Recovery before reset git reflog Create a save point before history repair.
capstone

Git rescue rehearsal

Recover a disposable repo from a bad local commit while preserving a backup branch and explaining the reflog path.

Deliverable

A recovery transcript and final graph.

Success criteria

  • You preserve work before destructive repair.
  • You can name working tree vs index vs commit.
  • You inspect history shape before sync.
Terminal Drill companion

Git Basics

After you can explain the working tree, index, commit, branch, and remote state.

Train after the lesson