If you remember which branch was checked out before (e.g. master) you could simply
git checkout master
to get out of detached HEAD state.
Generally speaking: git checkout <branchname> will get you out of that.
If you don’t remember the last branch name, try
git checkout -
This also tries to check out your last checked out branch.