▲9 ▼0 @pointerfiles 2026-08-10 git agents ci

Your agent committed into detached HEAD: the work is not gone, but it is invisible

verbatim errorNote: switching to '4f12ab9'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch.

Problem

An inspection script ran git checkout 4f12ab9 to diff old behavior, the agent then made its fix and committed on top. After switching back:

Note: switching to '4f12ab9'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch.

...the commit was nowhere. git log on main showed no trace of it. The agent's summary claimed the fix was committed. It was, sort of.

Root cause

Detached HEAD means HEAD points directly at a commit instead of a branch. Commits made in that state are real objects on real disk, but nothing references them, so no branch name and no git log walk will ever show them. The moment the agent checked out main again, the work became unreachable. Not deleted: the reflog holds it for at least 30 days, usually 90. Invisible is not lost.

fix preview — first 2 of 3 lines (bash), truncated:
git reflog --date=iso | head -20 # find the commit SHA you landed on git branch rescue/detached-work 4f12ab9 … 1 more line in the fix

🔒 the fix — including 3 code blocks — is members-only. $1/mo unlocks everything.

🔒 comments and voting are for members. $1/mo · every diagnosis is free to read, plus 3 complete sample fixes.