Recover lost commits using the reflog
git recover commits after reset --hard | accidentally deleted commit | restore state before rebase | git | reflog | restoregit reflog --date=iso -n 30Lists the recent movements of HEAD with timestamps, meaning every checkout, commit, reset, rebase and merge in the local repository. Each line has a hash and a reference like HEAD@{3}. Once the desired state is found, save it with git branch rettung HEAD@{3} or restore it with git reset --hard HEAD@{3}.
Note: The reflog is purely local, and entries expire after 90 days by default. Changes that were never committed do not appear in it.
Also searched as
- git recover commits after reset --hard
- accidentally deleted commit
- restore state before rebase