Module 9: Introduction to Git

Lesson 5 of 5 ยท 15โ€“25 minutes

Restoring changes

๐Ÿ The everyday picture

An "undo" button that works across days, for the whole project, and never forgets.

๐Ÿ“˜What it really is

๐Ÿ–ฑ๏ธTry it

  1. Make sure git status is clean.
  2. Delete all the text in index.html and save. (Pretend an AI did this.)
  3. Run git restore index.html. Your text is back.

โœ…Quick check

An AI edited ten files and broke your site. You committed just before asking it, and git status shows only those ten files as changed, nothing staged. What's the quickest way back?

Show the answer

From the project's top folder, git restore . puts those files back as they were at your last commit. It doesn't touch staged changes or brand-new files, so check git status afterwards.

Why is git revert safer than rewriting history?

Show the answer

It undoes a commit by adding a new one, so nothing is deleted and other copies of the project stay in step.

โ† PreviousStaging and history
ProLearners Assist