Overview
To inspect a previous project state, use:
git checkout <commit-id>
Git updates the working files to match that commit. The terminal reports a detached HEAD state because you are viewing a specific commit rather than working on the tip of a normal branch.
For example, if a later commit added a line to a file, checking out an earlier commit makes that line disappear from the working directory because the earlier saved state did not contain it.
Return to the latest state of the main branch with:
git checkout main
Before moving to an earlier commit, preserve pending work. Local changes that would be overwritten can prevent the checkout.