Exercise

Restoring an old version of a file

You previously saw how to use git checkout to undo the changes that you made since the last commit. This command can also be used to go back even further into a file's history and restore versions of that file from a commit. In this way, you can think of committing as saving your work and checking out as loading that saved version.

Your task is to restore a file to a previous version and update the repo so it contains this as the current version of the file.

Instructions 1/4

undefined XP
  • 1
    • Display the last two commits for the report file.
  • 2
    • Use the commit hash to restore the version of report.md from the second most recent commit.
  • 3
    • Put the restored version of report.md into the staging area.
  • 4
    • Commit the restored file with a log message of "Restoring version from commit 36b761".