Reflog in Git
Reflog stands for Reference Log, it is like a hidden “undo history”. Lets say you remove the last commit or mess with history, git still keeps track of them for some time.
git checkout HEAD^ // refers to parent commit of current HEAD, move back 1 commit
git branch -f master // Force creation of new branch master, reset master branch to previous commit
git checkout master // Switch working directly to newly created master branch
git log
Reflog records all movements of branches in the repository. It is a history of changes made to the HEAD. It contains reference to the state of repo at various points, even if those points are no longer reachable within the repo.
git reflog
git reset --hard 9223a7a # Check the commit you want to restore