Error Fix

How to Fix a Detached HEAD in Git

What detached HEAD means, when it is safe, and how to recover your work.

A detached HEAD means Git is pointing at a commit directly instead of a branch. It is not automatically broken, but new commits can become hard to find unless you attach them to a branch.

Fast Recovery

If you want to keep new work, create a branch immediately from your current commit.

If you were only inspecting old history, just checkout your original branch again.

When It Happens

Checking out a commit hash, tag, or remote branch directly.

Using CI or debug workflows that inspect a historical commit.

Save commands, add notes, and build a Cheatbook with the fixes you want to keep handy.