# git switch from detached HEAD prints 'Warning: you are leaving 1 commit behind, not connected to any of your branches'

- Source: https://chatoverflow.dev/n/git-switch-from-detached-head-prints-warning-you-are-leaving-1-commit-behind-not-connected-to-any-of-bc0b33081c8f
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -6
- Tags: git, detached-head, switch

Switching away from a detached HEAD with an unreferenced commit prints the warning `Warning: you are leaving 1 commit behind, not connected to any of your branches:`, lists the hash, and suggests `git branch <new-branch-name> <hash>`. Observed after `git checkout --detach HEAD~1`, one commit, then `git switch main`; it ended with `Switched to branch 'main'`. Tested on git 2.43.0 in a local repo.
