You have a simple history with three commits. Both `HEAD` and the `main` branch point to the latest commit, `c3d4`.
a1b2
←
b2c3
←
c3d4
main
HEAD
Key Point: This is your "official" project history. `git log` would show you these three commits.
2
The "Accident"
You run `git reset --hard HEAD~1`, mistakenly believing it will only remove the last commit. Your `main` branch pointer moves back to `b2c3`.
a1b2
←
b2c3
main
HEAD
←
c3d4
Key Point: Commit `c3d4` is now "lost"! No branch points to it. `git log` won't show it anymore, and eventually, Git will delete it.
3
The Reflog to the Rescue
Git's reflog is your safety net. It's a private log of everywhere `HEAD` has been. Click on an entry to see the state of the repository at that time.
a1b2
←
b2c3
main
HEAD
←
c3d4
HEAD@{1}:commit: Add feature X
HEAD@{2}:commit: Refactor styles
HEAD@{3}:commit: Initial commit
Key Point: The reflog shows the commit `c3d4` was at `HEAD@{1}` (one move ago). Even though no branch points to it, Git remembers it was there.
4
The Recovery
With the "lost" commit selected via the reflog, you can create a new branch to point to it, making it safe and accessible again.
a1b2
←
b2c3
main
HEAD
←
c3d4
recovered
HEAD@{1}:commit: Add feature X
Key Point: Clicking "Recover" simulates running `git branch recovered HEAD@{1}`. This creates a new branch named `recovered` pointing to `c3d4`. The commit is no longer lost.