Recovering Work with Reflog
git reflog records movements of references such as HEAD and local branches. It can often help recover commits that are no longer reachable through normal branch references, such as after an accidental reset.
Reflog entries are local and are not part of the shared repository history.
A commit disappearing from normal branch history does not immediately mean its objects are gone. Reflog can provide a route back while the relevant objects remain available.
git reflog
# Find the previous HEAD
git branch recovery abc1234
git switch recoveryAfter locating the desired historical HEAD position in the reflog, creating a new branch at that commit gives the commit a reachable reference again.
Reflog records local reference movements.
It is extremely useful after accidental reset or rebase operations.
Reflog is local and should not be treated as a shared backup.
What is git reflog especially useful for?