Visiting an Old Commit
Time travel.
What did the whole project look like back then? You can travel back, and look around, in any old commit. All your files change to exactly how they were.

- See the whole project, back then
- Every file changes
- Then come back
Going back
Right now we have three files. Let's travel to the second commit, zero b a six zero four nine. We type git switch, dash dash detach, and the hash. Git says head is now at that commit. Now list the files. Only index dot HTML. Back then, the about page and the styles didn't exist yet.
ls about.html index.html style.css git switch --detach 0ba6049 HEAD is now at 0ba6049 Add welcome text ls index.html
Coming home
To come back to the present, switch back to main. All three files are back. Nothing was lost. Time travel in Git is completely safe, as long as you only look around.
git switch main Previous HEAD position was 0ba6049 Add welcome text Switched to branch 'main' ls about.html index.html style.css
Summary
git switch dash dash detach visits any old commit, and git switch main brings you home. Next, what that scary detached head message means.
Key takeaways- git switch --detach <hash>
- Look around safely
- git switch main to return