What Does "Detached HEAD" Mean in Git?
A detached HEAD means you've checked out a specific commit instead of a branch. Learn what it means, why it happens, and how to save work made in this state.
Published September 19, 2026
A detached HEAD means HEAD points straight at a commit instead of a branch name, so new commits belong to no branch and can be lost. Create a branch with git switch -c name to keep them.
The concept
Normally HEAD points to a branch, and the branch points to a commit. When you check out a commit hash, tag or remote branch, HEAD points directly at that commit.
Commits you make in this state are reachable only from HEAD. Once you switch away, nothing references them and garbage collection will eventually remove them.
Attached vs detached
Practical examples
How you get here
git checkout a1b2c3d
# HEAD is now detached at a1b2c3dKeep your work
git switch -c my-fixJust go back
git switch mainRescue a commit after switching away
git reflog
git branch recovered <hash>Common mistakes
- Committing for hours while detached then switching away.
- Panicking — nothing is broken, it is just a state.
- Forgetting to push the new branch.
Key takeaways
- Detached = HEAD at a commit, not a branch.
- git switch -c saves new commits.
- reflog can recover orphaned commits.
FAQ
Is detached HEAD bad?
No, it is useful for inspecting old versions; just branch before committing.
How do I check where HEAD is?
git status shows 'HEAD detached at <hash>'.