Why does git say 'detached HEAD' and where did my commits go? #44
Answered
by
Kevinchamplin
Kevinchamplin
asked this question in
Q&A
-
|
Why does git say 'detached HEAD' and where did my commits go? |
Beta Was this translation helpful? Give feedback.
Answered by
Kevinchamplin
Jun 13, 2026
Replies: 1 comment
-
|
You checked out a specific commit or tag rather than a branch, so HEAD points straight at a commit instead of a branch ref. Commits you make there belong to no branch and will be lost to garbage collection once you switch away. To keep them, create a branch from where you are: |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Kevinchamplin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You checked out a specific commit or tag rather than a branch, so HEAD points straight at a commit instead of a branch ref. Commits you make there belong to no branch and will be lost to garbage collection once you switch away. To keep them, create a branch from where you are:
git switch -c my-branch(orgit branch my-branch <sha>if you already moved).