When you run git branch -r
why the blazes does it list origin/HEAD
? For example, there's a remote repo on GitHub, say, with two branches: master and awesome-feature. If I do git clone
to grab it and then go into my new directory and list the branches, I see this:
$ git branch -r
origin/HEAD
origin/master
origin/awesome-feature
Or whatever order it would be in (alpha? I'm faking this example to keep the identity of an innocent repo secret). So what's the HEAD
business? Is it what the last person to push
had their HEAD
pointed at when they pushed? Won't that always be whatever it was they push
ed? HEAD
s move around... why do I care what someone's HEAD
pointed at on another machine?
I'm just getting a handle on remote tracking and such, so this is one lingering confusion. Thanks!
EDIT: I was under the impression that dedicated remote repos (like GitHub where no one will ssh in and work on that code, but only pull or push, etc) didn't and shouldn't have a HEAD because there was, basically, no working copy. Not so?
@robinst is correct.
In git, you can select which branch is checked out by default (i.e. when you clone). By default, origin/HEAD
will point at that.
On GitHub, You can change this in the Admin settings for your GitHub repo. You can also do it from the command-line via
git remote set-head origin trunk
or delete it altogether via
git remote set-head origin -d
Example. Look at the 'Switch Branches' drop-down. trunk
is checked, so origin/HEAD
follows trunk
.