Skip to content
Back to library
intermediateBranches & HEAD

Detached HEAD

The Definition

Detached HEAD occurs when HEAD points directly to a commit instead of a branch reference.

Mental Model

"Detached HEAD is like being on a railway siding - you're still on the tracks, but not connected to a main line (branch). Any commits you make here won't be on a branch."

Visual Simulation

Live Engine
mainHEAD! DETACHED

Watch Out (Common Pitfalls)

!

Making commits in detached HEAD state and losing them

!

Not understanding how to recover from detached HEAD

!

Intentionally working in detached HEAD without knowing the consequences

Hands-on Command

shell
~ $git checkout a1b2c3d (checkout a commit hash)