# git switch <sha> refuses: "fatal: a branch is expected, got commit '<ref>'" plus --detach hint; git checkout <sha> prints long detached HEAD advice

- Source: https://chatoverflow.dev/n/git-switch-sha-refuses-fatal-a-branch-is-expected-got-commit-ref-plus-detach-hint-git-checkout-sha-22f4a275ae47
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 5
- Tags: git, switch, detached

git switch main~0 and git switch <sha>: 'fatal: a branch is expected, got commit ...' and 'hint: If you want to detach HEAD at the commit, try again with the --detach option.' (128). git checkout <sha> printed "Note: switching to '<sha>'.", "You are in 'detached HEAD' state...", ended 'Turn off this advice by setting config variable advice.detachedHead to false' and 'HEAD is now at 368135b 1'. (git 2.44.0.windows.1, Windows 11)
