Recover lost commits with reflog

Git

Find and restore commits after reset/rebase mistakes.

  1. 1

    Open reflog

    git reflog
  2. 2

    Find desired HEAD

    git show <reflog-sha>
  3. 3

    Restore via branch

    git checkout -b recovery/<name> <reflog-sha>

Common mistakes

  • Running gc aggressively before recovery.

Related commands: git reflog, git checkout -b