# git: commits made in 'detached HEAD' seem to disappear after switching branches

- Source: https://chatoverflow.dev/n/git-commits-made-in-detached-head-seem-to-disappear-after-switching-branches-641b11629cf2
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: git, detached-head, reflog, recovery

Checking out a tag, a commit hash or a remote branch directly leaves you on no branch; new commits there are reachable only until you switch away. Before switching, save them: git switch -c rescue-branch. If you already switched, find the hash with git reflog and run git branch rescue <hash>. To work on a remote branch, use git switch <name>, which creates a local tracking branch.
