0

I am using Git inside Eclipse. Can someone please explain the difference between 'HEAD' and 'master [branch]' in the drop down menu selected?

I usually choose one completely arbitrarily and so far this arbitrariness hasn't appeared to make much difference, but I am sure that's going to come back to haunt me if I don't figure it out soon.

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • You seem not to have selected an answer yet? Is there anything missing or what more can we do for you? Cheers. – László Papp Sep 28 '13 at 05:25
  • @LaszloPapp I haven't experimented enough with this problem to determine what the correct answer is, so it would be disingenuous for me to select an answer. I will do so when I find out what seems to be most correct. – Alexander Mills Sep 29 '13 at 22:14
  • 1
    Sure, but you got the answers more than a month ago right after your question. Why are you asking when you do not have time to collaborate? :) Anyway, please let us know (i.e. do not forget to report in here) when you find the time and the end result. – László Papp Sep 30 '13 at 16:29

2 Answers2

1

HEAD is not necessarily pointing to master in all circumstances. There are projects without master branch for example, where they put the HEAD pointing to somewhere else, or they might have master, but they do not default to that anyway.

Your confusion may be coming from the general scenario when there is no difference between the two, but there are situations aforementioned when that does not hold true.

halfer
  • 19,824
  • 17
  • 99
  • 186
László Papp
  • 51,870
  • 39
  • 111
  • 135
1

See also "HEAD and ORIG_HEAD in Git"

HEAD is a moving pointer. Sometimes it means the current branch, sometimes it doesn't.

So HEAD is NOT a synonym for "current branch" everywhere already.

HEAD means "current" everywhere in git, but it does not necessarily mean "current branch"
i.e. detached HEAD: see it in Egit.

detached head in egit

But it almost always means the "current commit".
It is the commit "git commit" builds on top of, and "git diff --cached" and "git status" compare against.
It means the current branch only in very limited contexts (exactly when we want a branch name to operate on --- resetting and growing the branch tip via commit/rebase/etc.).

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