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

Re: mirror clone does not keep HEAD updated

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 5, 2023, 01:38 UTC
Message-ID
<CAMP44s1TBUmc6mhGSWQ1v+E5_VRqnCUXURHs2cM-vE22eyndsQ@mail.gmail.com>
In-Reply-To
<harpgnimhcdp2m6hww7ht7pgxvchllvrncnwoxkivaorb5xhm7@5rcr2p7hcp4x>
On Tue, Apr 4, 2023 at 11:35 AM Daniel Martí <mvdan@mvdan.cc> wrote:
>
> I'm testing `git clone --mirror` to properly mirror a repository on
> github.com. It appears to be working well, except for keeping HEAD
> correctly in place.

Git does not set or update the remote HEAD, that's something the user is supposed to do (for some reason).

The only exception is when cloning a repository.

In my opinion this is completely unintuitive and unhelpful. 99.99% of the time I want the remote HEAD to be pointing to where the remote's HEAD is pointing to.

I implemented patches to fix that [1], but they were never merged.
It's particularly wrong when you are mirroring a repository, as in your case.
> Am I holding the mirror wrong somehow? As far as the manpages say, `git
> remote update` should be enough to fully mirror all refs.
That's what I would expect, but that's not true.

I find that most of the time I need to read git's code to actually understand what it's supposed to do. I don't bother reading the documentation.

I've updated my old RFC patch adding tests and an option to make it work with mirrored repositories as well. With `fetch.updateHead=always` the mirrored clone always has the HEAD up-to-date.

Cheers.

[1] https://lore.kernel.org/git/20201118091219.3341585-1-felipe.contreras@gmail.com/ [2] https://lore.kernel.org/git/20230405012742.2452208-1-felipe.contreras@gmail.com/T/#ma012c4823814936a3ab8755d1d2b805d61b43133

-- 
Felipe Contreras
Previous: Felipe Contreras
Message 4 of 4 in “mirror clone does not keep HEAD updated”
  1. Daniel MartíApr 4, 2023
  2. Junio C HamanoApr 4, 2023
  3. Felipe ContrerasApr 5, 2023
  4. Felipe ContrerasApr 5, 2023

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.