3

I have come across this quora question where two answers pointed out that there can be only one head and one answer that there can be more than one HEAD.

Additionally I have found medium article where author stated that there can be any number of heads within a repo ("A repository can contain any number of heads.").

Now I am confused and would be thankful if somebody could please give a hint in this subject.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
grabeqc
  • 95
  • 6
  • 1
    Does this answer your question? [What is HEAD in Git?](https://stackoverflow.com/questions/2304087/what-is-head-in-git) – TonyArra Apr 23 '22 at 18:49
  • 2
    Git is case-sensitive, like English. "The Polish man applied shoe polish" and "the polish man wore a Polish shoe" are correct sentences, and "the Polish man wore a Polish shoe" is also correct but means something entirely different from the middle sentence. – torek Apr 23 '22 at 20:03

1 Answers1

5

one answer that there can be more than one HEAD

That answer is referring to the most recent commit of a branch.
They are listed in .git\refs\heads.

That differs from @ (HEAD), which is in .git/HEAD, and which represents where you are:

  • either a branch
  • or a commit ("detached HEAD")

While there can be as many heads there are branches, there can be only one HEAD, since you cannot be at multiple places at once.
Unless you count git worktree list, which would list multiple working trees attached to the same repository... each with their own HEAD!

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250