0

I am confused about HEAD pointer in the git branch -a output, which is not explained in the documentation.

  • I have an origin repository with a master-branch and a branch nipunbatra-patch-1.
  • I have another remote repository NILMTKtoENERGYTK.
  • My local repository has a masterbranch and a my-branchto which I want to add the changes from the NILMTKtoENERGYTK repo.

enter image description here

Why is there only a HEAD label in the origin repo and neither in the NILMTKtoENERGYTK nor in the local repo? And which implications does it have for me?

BaluJr.
  • 1,010
  • 2
  • 11
  • 25

1 Answers1

1

In this case, HEAD is a symbolic reference to the origin remote's default branch, i.e. the branch that gets checked out when doing a git clone. While it's common for remotes to have that symbolic reference, it's not required, and some remotes might not have defined it on the server side.

sschuberth
  • 28,386
  • 6
  • 101
  • 146
  • Is it really about beeing 'defined' or not? I turned arround the order of the two remote repositories. `NILMtoENERGYTK`becomes the origin and the previous origin is added as additional remote. In this case again only the origin, the repo without the HEAD pointer before, has this HEAD pointer. So it must have some meaning!? – BaluJr. May 03 '18 at 08:54
  • Well, on the initial `git clone` your local `remotes/origin/HEAD` is set to whatever the server-side's `HEAD` points at, if any. But you can change your local `remotes/origin/HEAD` manually afterwards, like you probably did. Also see the documentation for [git remote set-head](https://git-scm.com/docs/git-remote#git-remote-emset-headem) and [this question](https://stackoverflow.com/questions/8839958/how-does-origin-head-get-set). – sschuberth May 03 '18 at 09:00
  • `set-head` is what I was looking for. If I set the HEAD manually it does also show up in the `git branch -a` output. – BaluJr. May 03 '18 at 09:08