If there are no commits on the detached head, just do this:

    git checkout master

Else save your commits on a new branch first:

    git checkout -b temp
    git branch -f master temp
    git checkout master