Fix · GitHub and Git
"You are in detached HEAD state"
What you may see
- Git says detached HEAD and my commits seem to belong to no branch
- I checked out an old version and now I am lost
Most likely cause
You moved to a single old save point, not onto a branch, so new commits have no branch to live on.
Check first (about two minutes)
- Run git status: it says HEAD detached at <hash>.
- Run git log --oneline -3 and see if any commit is newer than the branch.
The fix prompt
What you type here never leaves your browser. The search runs on this page, and nothing is sent to a server or to an AI.
Kept only in this browser, on this device. Keys and passwords are removed before anything is saved.
Prompt language
Paste it into Claude, ChatGPT, Gemini or Cursor, then follow what it says.
After you tried it, did it work?
Steps
- Run git status and git log --oneline -5 and show me.
- If I made new commits here, save them first: git switch -c rescue-work.
- If I made no changes, go back with git switch main (use the real branch name).
- Explain how to look at an old version safely next time.
Do not do this
- Do not run git reset --hard here.
- Do not run git checkout of another branch before saving new commits.