I am trying to contribute to core as I did the last seven or so years and I need to waste my time on git. This is extremely frustrating. By now, I understand the concept of git repositories and branches (co-located branches do not make any sense but that's git for you) but when I do git clone -b 7.x git://git.drupal.org/project/drupal.git and run git branch -a I see, among others remotes/origin/HEAD -> origin/7.x. Now, that's extremely confusing. To my understanding "origin" was a label we used for a URL push and pull used by default ( as I wrote http://drupal.org/node/1059322/revisions/view/1374826/1388912 here ). What does this has to do with branches? (A branch, to the best my understanding are just labels on a commit with a twist -- they move to the next commit as it happens.) So what is remotes/origin and what is origin, what is the difference and why they are listed in branches?

Comments

chx’s picture

BTW I created http://drupal.org/node/1137316 as the day progressed to document what I understand of the core repo and how the magic incantations for core are diferent to contrib. Edit: the remotes/origin construct appears there as well and I do not understand that either.

chx’s picture

I think origin/foo is the foo branch as it is on the origin server ( I *think* ) but ... how does origin/foo differ from remotes/origin/foo?

And just from looking at this mysterious line, did someone set up the Drupal project so that if someone just clones it without specifying anything (that's what HEAD is, isn't it?) then they get 7.x? If so, how can I do it myself? That'd be quite handy for contrib as well.

damien tournoud’s picture

Priority: Critical » Normal

"HEAD" is a symbolic reference, a way to alias references (branches, tags or commits):

  http://www.kernel.org/pub/software/scm/git/docs/git-symbolic-ref.html

The mechanism is used for only one thing in Git, as far as I know, to alias "HEAD" to the default branch that gets checked-out when you clone a repository.

damien tournoud’s picture

One thing is critical to understand: Git collapses object names ("references") by default, and allows you to use short-hand notations for them.

The exact rules used to resolve symbolic identifiers are described in http://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html

But in a nutshell:

  • 7.x is a short-hand for refs/heads/7.x if you have a local 7.x branch
  • 7.0 is a short-hand for refs/tags/7.x if you have a local 7.0 tag
  • origin/7.x is a short-hand for refs/remotes/origin/heads/7.x
chx’s picture

OK. So questions

  1. origin/7.x and remotes/origin/7.x are both the same thing (refs/remotes/origin/heads/7.x). git only uses two different notations in git branch -a because...?
  2. See the "how do i do it myself" in #2
damien tournoud’s picture

No idea why there are two notations in that screen.

Configuring HEAD is the point of #1074960: Let maintainers set a default branch on git repositories.

eliza411’s picture

Status: Active » Fixed

I think this is resolved for sure now that #1074960: Let maintainers set a default branch on git repositories has been deployed. If I'm mistaken, please re-open.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.