A detached HEAD occurs when HEAD points directly to a commit rather than to a branch. It's a normal state (not an error) that happens when you check out a specific commit, tag, or remote commit — but committing in it risks losing work, so understanding it is important.
What HEAD normally points to
NORMALLY: HEAD → a BRANCH (e.g. main) → a commit
→ when you commit, the branch pointer advances, and HEAD follows it
DETACHED: HEAD → directly to a COMMIT (not through a branch)
→ you're "not on any branch" — looking at a specific commit
