Being in detached head means that the head value is:
Consequences:
You will be set in a detached mode when you don't checkout a local branch and you will see the following text
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 switching back to a branch.
For instance:
# ie parent commit of main
git checkout main^
# grandparent of current HEAD
git checkout HEAD~2
git checkout remote/branchName
# for instance
git checkout origin/main
git checkout tagname
The head value is:
ref: refs/heads/branch.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Turn off this advice by setting config variable advice.detachedHead to false