What is a detached HEAD state in Git?
Short answer: A detached HEAD occurs when Git’s HEAD (which points to your current branch) points to a specific commit instead of a branch.
Explain a bit more
This means you’re not working on any branch — any new commits made in this state are “orphaned” unless you create a branch from them. Example: If you check out an old commit directly: git checkout a1b2c3d You’re in a detached HEAD state. If you make changes here and don’t create a new branch, you could lose them later. Fix: Create a new branch to save your work: git checkout -b hotfix/rollback-test
Real-world example (ShopNest)
ShopNest’s team uses GitHub PRs with reviews and CI checks so broken builds never reach production unnoticed.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png