Detached HEAD występuje, gdy HEAD wskazuje bezpośrednio na commit zamiast na gałąź. To normalny stan (nie błąd), który pojawia się, gdy sprawdzisz konkretny commit, tag lub zdalny commit — ale tworzenie commitów w tym stanie grozi utratą pracy, dlatego zrozumienie go jest ważne.
Co HEAD zwykle wskazuje
NORMALLY: HEAD → a BRANCH (e.g. main) → a commit
→ when you commit, the branch pointer advances, and HEAD follows it
DETACHED: HEAD → directly to a COMMIT (not through a branch)
→ you're "not on any branch" — looking at a specific commit
Kiedy pojawia się detached HEAD
git checkout <commit-hash>
git checkout v1.0.0
git checkout origin/main
