-1

Not the current working HEAD REFERENCE which points in our current branch.

2

You can directly see HEAD if you look into the file .git/HEAD. What you find in there is all there is to it, there is nothing more.

HEAD does not, strictly, point to the current branch but is the commit that is currently checked out. It is, by definition, the first entry that git log lists.

If you do a git checkout branchname then, yes, indeed, .git/HEAD will contain the ref of the branch you checked out, probably something like refs/head/branchname. This in turn is literally the file that contains the actual commit hash; you can see it in .git/refs/head/branchname. But if you do git checkout commithash then .git/HEAD will contain said hash, and you will be in a "headless" state (git will give you a longish message explaining what that is). In this case, there is no "current branch".

  • Hi thanks, when we move file to staging area, one temp ref head id will create in local repository which stating current working commit(commiting by some one else).Not the head that showing in our current branch – Vinodh Machi Oct 10 '17 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.