Detached HEAD
Definition
With Detached HEAD, Git points directly to a commit instead of a branch.
Detached HEAD is a Git state in which HEAD directly references a commit. You can examine a previous state and create new commits. However, these do not move any branch pointer; for permanent further work, an appropriate branch should be created.
Simply explained
You are viewing a specific checkpoint without being on a named development branch.
Why it matters in practice
This state is useful for targeted investigations of old versions but requires attention when making new changes.
Example from business
Possible example: A developer opens an earlier commit to check whether a reported bug was already present there.
Limits and pitfalls
- New commits can become hard to find after leaving without a branch. Detached HEAD is not an error and does not mean the repository is damaged.
Origin & history
Git distinguishes the current reference point HEAD from named branches; this separation allows direct visits to individual versions.
Use in mid-sized companies
- Teams use this state for investigations and create a branch referencing the new state before permanent further work.
Frequently asked questions
Are changes lost immediately?
No. But they require a reachable reference; a branch makes new commits reliably usable going forward.
Sources
- git-checkout, Abschnitt DETACHED HEAD. · Git (o. J.): git-checkout, Abschnitt DETACHED HEAD.
Editorially reviewed on: