git reflog command

The git reflog command goes through a log of where all the heads of your branches have been as you work to find commits you may have lost through rewriting histories.