Incerteza
Incerteza

Reputation: 34884

HEAD doesn't point to the current branch?

I wonder, is not HEAD is the current branch? As far as I'm concerned it is. But this shows that this is not the case:

$ git branch
* develop
  master

So the current branch is develop. But HEAD is not:

 $ git branch -r
  origin/HEAD -> origin/master
  origin/develop
  origin/master

Upvotes: 0

Views: 4567

Answers (2)

user456814
user456814

Reputation:

HEAD in your local repository references the currently checked-out commit, which may or may not also be the location of a branch. So HEAD in a local repository does not always refer to the currently checked-out branch. For example, you can enter a "detached HEAD" state by checking out a commit directly.

However, in the context of remote repositories, HEAD refers to the default branch for that remote. So

origin/HEAD -> origin/master

means that the default branch on origin is the master branch.

Upvotes: 1

xdazz
xdazz

Reputation: 160833

You use the -r option, so it lists the remote-tracking branches.

  origin/HEAD -> origin/master

means the HEAD in the remote refs the HEAD of remote branch origin/master.

Upvotes: 1

Related Questions