git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: RFC for 1.7: Do not checkout -b master origin/master on clone

From
SBSanti Béjar <santi@agolina.net>
Date
Aug 11, 2009, 21:06 UTC
Message-ID
<adf1fd3d0908111406w1ccae22fp3f26ecb89c67fa5e@mail.gmail.com>
In-Reply-To
<4A818B90.9050206@drmicha.warpmail.net>
2009/8/11 Michael J Gruber <git@drmicha.warpmail.net>:
Show 8 quoted lines
> One common source of confusion for newcomers is the fact that master is
> given such a special treatment in git. While it is certainly okay and
> helpful to set up a default branch in a new repository (git init) it is
> not at all clear why it should be treated specially in any other
> situation, such as:
>
> - Why is master the only local branch which git clone sets up (git
> checkout -b master origin/master)?
Because master is the default branch in the remote repository?
[...]
> This behaviour not only is hard to justify; in fact it gives users a
> completely wrong impression: by pretending that master is special,

It is not hard to justify (the git clone behavior). master is not special, it is just the default branch, but you can change it changing the HEAD symlink.

Show 12 quoted lines
> but
> also by hiding core concepts (distinguishing local/remote branches,
> detached heads) from the user at a point where that very hiding leads to
> confusion.
>
> Under the hood, it is of course HEAD which is given special treatment
> (and which in the majority of repos points to master), and git clone
> sets up a local branch according to HEAD (and does some other guess work
> when cloning bare repos), which means that git clone shows the same
> "random" behaviour which git svn clone does: Which local branch is set
> up by default depends on the current value of HEAD/most recent commit at
> the time of the cloning operation.
It's not random. And please don't mix the "git clone" and "git svn" case.
> So, I suggest that starting with git 1.7:
>
> - git clone does not set up any local branches at all

I think you should first think if this is going to really help newcomers. I think this would be worst.

Instead of "why only 'master'?" the question will be "why I don't get any files in the workdir?"

"git clone checks out the default branch, and this is 'master' by default" is not that hard.

HTH, Santi

Previous: Michael J GruberNext: Junio C Hamano
Message 2 of 5 in “RFC for 1.7: Do not checkout -b master origin/master on clone”
  1. Michael J GruberAug 11, 2009
  2. Santi BéjarAug 11, 2009
  3. Junio C HamanoAug 12, 2009
  4. Eric WongAug 12, 2009
  5. Matthieu MoyAug 17, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.