HEAD is a special ref. It always points to the current object.
You can see where it’s currently pointing by checking the .git/HEAD file.
Normally, HEAD points to another ref:
$cat .git/HEAD
ref: refs/heads/mainline
But it can also point directly to an object:
$ cat .git/HEAD
4bb6f98a223abc9345a0cef9200562333
This is what’s known as a “detached head” - because HEAD is not attached to (pointing at) any ref, but rather points directly to an object.