HEAD detached at the HEAD commit id, what's the meaning?
Asked Answered
L

1

11

git status says:

HEAD detached at e1997bd

and git rev-parse HEAD says:

e1997bd

What's the meaning of this?

I was thinking HEAD detached means HEAD is not pointing to to branch tip.

Lagrange answered 16/7, 2015 at 16:2 Comment(2)
possible duplicate of How can I reconcile detached HEAD with master/origin?Dunstan
See this answer: #25670673Gamopetalous
S
18

Read through: http://gitolite.com/detached-head.html

You can also look at: http://gitolite.com/gcs.html#(48)

The head points to the commit, that's not the problem. The problem is that it's no longer a reference to a local branch name. It's the actual SHA1 hash of the commit.

This may have happened if you did:

git checkout <commit_id>
  -- or --
git checkout origin/master

To fix this, do

git checkout <branch_name>
Spirometer answered 16/7, 2015 at 16:11 Comment(2)
Can also happen if you checkout a remote tracking branch e.g. origin/masterBanksia
I did git checkout <commit_id> but it doesn't recognize any remote branches. Trying to checkout another branch gives the same error as trying to get a new commit. pathspec <branch name or commit_id> did not match any file(s) known to gitGifford

© 2022 - 2024 — McMap. All rights reserved.