0

I am using TortoiseGit for Windows. I see two branches on remote/origin:

HEAD        20 minutes ago      Some commit message.
master      20 minutes ago      Some commit message.

I am confused why HEAD shows up as a branch; I did not explicitly create a separate branch on origin - it should only be 'master'. It's not really a problem, since they seem to update together anyway.

If I execute git branch on origin, it only shows 'master'.

Why are there two branches? Is this a TortoiseGit-specific thing, or a Git-specific thing? Thanks!

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Harper
  • 1,285
  • 3
  • 15
  • 35
  • Does this answer your question? [What is HEAD in Git?](https://stackoverflow.com/questions/2304087/what-is-head-in-git) – Gino Mempin Aug 11 '22 at 03:44

3 Answers3

1

It's a git-specific thing. HEAD is a reference to the currently checked out thing, i.e. usually a branch. In your case, HEAD is simply an alias for master. TortoiseGit apparently can't tell an alias ("symbolic ref") from a normal branch, so it appears as if HEAD is an extra branch when it really isn't.

The situation is a bit different for remote repositories which usually don't have anything checked out at all. You seem to be looking at a remote repository here. In that case, that repository's HEAD is used to determine which branch is checked out by default when someone clones that repository. That's why, when you clone, some branch or another is checked out: git doesn't just randomly pick a branch, but it looks at the source repository's HEAD to make that decision.

Jan Krüger
  • 17,870
  • 3
  • 59
  • 51
0

HEAD is the current revision. It's best answered by this question right here. It will be exactly the same as the currently checked out ref.

Community
  • 1
  • 1
Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
0

HEAD is the current "head" of the remote repo and would usually be same as the master. It is the current checked out branch / ref and is from the .git/HEAD file in the repo which has content like:

ref: refs/heads/master
manojlds
  • 290,304
  • 63
  • 469
  • 417