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

Re: [RFC/PATCH] Add fetch.updateHead option

From
Jeff King <peff@peff.net>
Date
Nov 24, 2020, 06:58 UTC
Message-ID
<X7yvJkCHa0+mpwPr@coredump.intra.peff.net>
In-Reply-To
<CAMP44s0E+e11jGFDa1zLK5Tv+2Zuv-_wXNF0NysoqEjtMgv0Pw@mail.gmail.com>
On Fri, Nov 20, 2020 at 07:18:39PM -0600, Felipe Contreras wrote:
Show 8 quoted lines
> On Fri, Nov 20, 2020 at 6:40 PM Jeff King <peff@peff.net> wrote:
> 
> > I don't think we do advertise the symref in such a case. In v2, the
> > symref information is attached to individual lines in the ref
> > advertisement. And we don't advertise the unborn line (we could, but I
> > think we might need a special syntax for the oid field).
> 
> This may be worth considering changing.

I agree it might be nice, but may not be worth the effort (it will require a protocol extension).

However...
Show 15 quoted lines
> If a hosting provider (e.g. GitHub) decides to configure an initial
> branch (e.g. main) it would be nice for "git clone" to have
> information about that initial branch so the user doesn't have to
> change it manually to please the provider's aesthetics.
> 
> So the instructions could be:
> 
>   git clone $url .
>   echo "# myproject" >> README.md
>   git add README.md
>   git commit -m "first commit"
>   # git branch -M main # this step would not be necessary
>   git push -u origin HEAD
> 
> Personally I don't care about this. But others might find it useful.

I don't think you have to do the rename here if you don't want to. If there is already content on the "main" branch at GitHub, then clone should pick that as the default branch for your local clone.

If there isn't, then you'll get whatever your local git-clone decides on. But when you push, at least to GitHub, if the server-side HEAD points to an unborn branch, it will re-point to the newly pushed branch. So with the current version of Git, you would end up with "master" on the remote side. And that should continue to work as it always has (AFAIK any changes on GitHub's side are purely about default branch names, such as when you add template files as part of the repo initialization).

Of course if you _want_ "main" in both cases, you'd have to rename the branch. But you would probably set init.defaultBranch in that case.

-Peff
Previous: Felipe ContrerasNext: Felipe Contreras
Message 10 of 13 in “Add fetch.updateHead option”
  1. Add fetch.updateHead optionFelipe Contreras, Nov 18, 2020
  2. Ævar Arnfjörð BjarmasonNov 18, 2020
  3. Felipe ContrerasNov 18, 2020
  4. Junio C HamanoNov 18, 2020
  5. Felipe ContrerasNov 18, 2020
  6. Jeff KingNov 20, 2020
  7. Junio C HamanoNov 21, 2020
  8. Jeff KingNov 21, 2020
  9. Felipe ContrerasNov 21, 2020
  10. Jeff KingNov 24, 2020
  11. Felipe ContrerasNov 21, 2020
  12. Felipe ContrerasNov 21, 2020
  13. Jeff KingNov 24, 2020

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.