Govur University Logo
--> --> --> -->
...

You accidentally performed `git reset --hard HEAD~3`, losing commits that were not pushed. How would you use `git reflog` to find and restore your branch to its state *beforethis `reset`?



When you execute `git reset --hard HEAD~3`, you are instructing Git to move the current branch pointer and your HEAD three commits backward in the history. This command also aggressively discards any changes in your working directory and staging area that were introduced by those three most recent commits, effectively removing them from your branch's visible history. While these commits are no longer part of your active branch, they are not immediately deleted from Git's object database; they simply become unreachable from any branch or tag. Git provides a powerful mechanism called the reflog to track every time your HEAD or other branch references change, which is essential for recovery in such scenarios.