Git Reflog & Recovering History
Master `git reflog` to recover lost commits or branches, providing a safety net for your work.
What is Git Reflog?
Ever accidentally delete a branch or reset to the wrong commit? Don't panic! Git has a powerful safety net called the Reflog.
The reflog (reference log) is a record of where your HEAD and branch pointers have been in your local repository.
How Reflog Tracks History
Unlike the commit history (git log) which tracks changes in your project files, the reflog tracks changes to your repository's references.
Every time your HEAD (your current commit) or a branch pointer moves, Git records this event in the reflog. This includes:
- Committing changes
- Switching branches
- Merging or rebasing
- Performing a reset
- Cloning a repository
All lessons in this course
- Git Reflog & Recovering History
- Git Bisect for Debugging
- Repository Maintenance & Housekeeping
- Rewriting History with git filter-repo