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

Re: `git fetch` not updating 'origin/HEAD' after branch rename

From
Jeff King <peff@peff.net>
Date
Apr 14, 2021, 05:29 UTC
Message-ID
<YHZ9w6MVMMHMxGeA@coredump.intra.peff.net>
In-Reply-To
<CAPx1GvdeNEyPEZ7GdRKeAevnvjyLmoXHjQP0W6iToDsJPAqDHA@mail.gmail.com>
On Tue, Apr 13, 2021 at 05:26:02PM -0700, Chris Torek wrote:
Show 21 quoted lines
> On Tue, Apr 13, 2021 at 5:18 PM Sam Bostock <sam.bostock@shopify.com> wrote:
> > Long story short, it seems to me that `git fetch` should update
> > "refs/remotes/origin/HEAD" when the upstream HEAD changes, but it
> > doesn't.
> 
> It's never been the *intent* to have `git fetch` update
> the corresponding remote-tracking `HEAD` ref.  To make
> that happen, you must run `git remote`:
> 
>     git remote set-head origin -a
> 
> for instance.
> 
> I have, however, often thought that this is the wrong
> *default* way for things to work, and that at least by default,
> `git fetch origin` should update `origin/HEAD` if the
> fetch result indicates that it should.  See also Junio's
> reply.  I think a configuration knob (similar to `fetch.prune`)
> would be reasonable here.  Users could then be encouraged
> to set `fetch.prune` to `true`, and `fetch.update-remote-HEAD`
> (or whatever) to `true` as well.
I think so, too. The previous discussion Junio referred to it is here:
  https://lore.kernel.org/git/20201118091219.3341585-1-felipe.contreras@gmail.com/

If you do read it, note that the parts of the conversation about unborn heads are out of date. We do pick this up via clone these days, courtesy of the commits in 69571dfe21 (Merge branch 'jt/clone-unborn-head', 2021-02-17).

-Peff
Previous: Chris TorekNext: Ævar Arnfjörð Bjarmason
Message 6 of 10 in “`git fetch` not updating 'origin/HEAD' after branch rename”
  1. Sam BostockApr 13, 2021
  2. Junio C HamanoApr 13, 2021
  3. Andreas SchwabApr 13, 2021
  4. Junio C HamanoApr 13, 2021
  5. Chris TorekApr 14, 2021
  6. Jeff KingApr 14, 2021
  7. Ævar Arnfjörð BjarmasonApr 14, 2021
  8. Andreas SchwabApr 14, 2021
  9. Junio C HamanoApr 14, 2021
  10. Jeff KingApr 15, 2021

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.