

Lesson 05 · 12 min
Undo carefully
restore discards edits in a file. revert adds a reverse commit. reset --hard on a shared branch — no.
12 minLesson 5 of 8Practice includedAsk AI on any point
Messed up a file before add: git restore file brings back the version from the last commit. Already added but not committed: git restore --staged file unstages it. The commit has already gone to origin — not reset --hard, but git revert: a new commit that undoes the old one. The shared history stays honest.
Sign in to continue
The rest of this lesson opens after sign up
The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.