Detached HEAD in Git: Diagnose It, Recover Your Commits, and Reattach Safely
Git says 'HEAD detached' and your commits feel one wrong command away from disappearing. Diagnose the state, save unreferenced work with a branch or the reflog, and reattach safely.