Explore Old Commits with a Detached HEAD, and then Recover

InstructorChris Achard

Share this video with your friends

Send Tweet

To poke around in old code, we can checkout the hash of an old commit with git checkout [HASH] - but then we'll be in a "detached HEAD" state.

Detached HEAD just means that HEAD is not pointing to a branch. That's problematic if we want to save the work that we do in that state - so we first have to make a new branch where we are with git checkout -b my-new-branch

Then, any changes we make can be committed to that new branched and saved.