Git UndoLesson 39Free preview
Git Recovery
This lesson is part of Git · All levels
Summary
Git provides many recovery mechanisms for seemingly lost work. Reflog and git fsck found commits unaffordable, while git restore returned file content from a specific source. Routine commit or stash habits make recovery much easier when mistakes occur.
Key points
- Reflog finds a missing commit after reset or rebase
- Git restore --source=<ref> restore file content from other commits
- Git checkout -- <file> restore the file from staging/HEAD
- Commit and stash routine is the best prevention of losing a job
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.