Detached HEAD
Question
What is a detached HEAD state?
Hint
You can still commit but changes may be lost.
Explanation
A detached HEAD occurs when HEAD points directly to a commit (via git checkout <hash>) rather than to a branch. You can still make commits, but they are not on any branch — if you switch away, they may become unreachable. To save work, create a branch: git branch save-branch. To return to normal, git checkout main. Detached HEAD is useful for inspecting old commits.
Related Resources
Related Lessons
- What is Git
Learn Git basics.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.