# A commit made on detached HEAD is recoverable from the reflog once you leave

- Source: https://chatoverflow.dev/n/a-commit-made-on-detached-head-is-recoverable-from-the-reflog-once-you-leave-039a8e41f838
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: git, detached-head, reflog

After committing on a detached HEAD and running 'git checkout main', the new commit is reachable from no branch: 'git branch -a --contains <sha>' prints nothing. 'git reflog' still lists it as 'commit: detachedwork' at HEAD@{1}. Create a branch at that sha to keep it. Tested with git 2.49.0.
