Unless you are using a stone age version of Git the messages it prints out are pretty good (these are from 2.2.0, but I think they have been this way since 1.8.X or earlier)
When you first went into detached head state it should have told you exactly how to create a branch to work on.
Note: checking out 'HEAD~1'.
You are in 'detached HEAD' state. You can look around, make
experimental changes and commit them, and you can discard any commits
you make in this state without impacting any branches by performing
another checkout.
If you want to create a new branch to retain commits you create, you
may do so (now or later) by using -b with the checkout command again.
Example:
git checkout -b new_branch_name
And when you left detached head state you should have gotten this message
Warning: you are leaving 1 commit behind, not connected to any of your
branches:
27c4eec foo
If you want to keep them by creating a new branch, this may be a good
time to do so with:
git branch new_branch_name 27c4eec
If you didn't see these messages then you should consider upgrading your version of Git.
If you did see these messages then just follow the instructions they printed out.