Chapter 8. Recovering from Mistakes

In this chapter, we will cover the following topics:

  • Undo – remove a commit completely
  • Undo – remove a commit and retain the changes to files
  • Undo – remove a commit and retain the changes in the staging area
  • Undo – working with a dirty area
  • Redo – recreate the latest commit with new changes
  • Revert – undo the changes introduced by a commit
  • Reverting a merge
  • Viewing past Git actions with git reflog
  • Finding lost changes with git fsck

Introduction

It is possible to correct mistakes made in Git the with git push context (without exposing them if the mistake is found before sharing or publishing the change). If the mistake is already pushed, it is still possible to undo the changes made to the commit that introduced the mistake. ...

Get Git: Mastering Version Control now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.