Chapter 3: Version control

A commit you think you lost is rarely gone.

Reflog

Git's private diary of everywhere HEAD has been: each commit, checkout, reset and rebase. When a commit seems lost, it is usually listed here, and you can walk straight back to it.

This is the real undo, and what makes it reasonable to let an agent move fast: anything it committed can usually be recovered, even after a bad reset or rebase. Its limits matter as much. It is local to one machine, it expires, and it knows nothing about work that was never committed.

Say it to your agent

“You reset past my work. Run git reflog, find the last entry before the reset, tell me its hash and message, and make a branch there with git branch rescue and that hash. Don't run gc, and don't reset anything else.”

The workshop

Name a word, or describe what you mean in everyday language.