You are in 'detached HEAD' state.
HEAD points at a commit instead of a branch, so new commits won’t belong to any branch.
Seen on:
Git
Meaning
Checking out a tag, a commit hash or a remote branch directly detaches HEAD. Commits made here can be lost when you switch away unless you create a branch.
Common causes
- git checkout <commit/tag>
- git checkout origin/main instead of main
- Interrupted rebase
- CI systems checking out a specific SHA
⚡ Quick fix
- Create a branch to keep work: git switch -c my-work
- Return to a branch: git switch main
- Recover lost commits with git reflog
Detailed fix by platform
Git
- bash
git switch -c fix-from-detached git reflog # find commits made while detached
How to diagnose
- State — git status shows "HEAD detached at"?
- Commits — Any new commits to keep?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026