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

mirror clone does not keep HEAD updated

From
Daniel Martí <mvdan@mvdan.cc>
Date
Apr 4, 2023, 16:16 UTC
Message-ID
<harpgnimhcdp2m6hww7ht7pgxvchllvrncnwoxkivaorb5xhm7@5rcr2p7hcp4x>
Hello all,

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.

For example, here is what I did:
	$ git clone --mirror https://github.com/mvdan/test-repo
	$ cd test-repo
	$ git branch -a
	* main
	$ git log HEAD
	commit d1adda533e90692e02ae837233368fbcca2a0e49 (HEAD -> main)
	[...]

If I then go on the GitHub web UI to rename the default branch from "main" to "newmain", `git remote update --prune` sees that:

	$ git remote update --prune
	From https://github.com/mvdan/test-repo
	 - [deleted]         (none)     -> main
	 * [new branch]      newmain   -> newmain
However, HEAD stops working:
	$ git log HEAD
	fatal: your current branch 'main' does not have any commits yet

Am I holding the mirror wrong somehow? As far as the manpages say, `git remote update` should be enough to fully mirror all refs. And my understanding is that using HEAD is correct, that I do not need to use origin/HEAD like in a regular git clone.

I also tried what I would usually do to sync origin/HEAD in a regular git clone, but unsurprisingly, that does not work:

	$ git remote set-head origin -a
	error: Not a valid ref: refs/remotes/origin/newmain

Any pointers appreciated. Assuming I'm not missing anything obvious here, this might be a bug in `git remote udpate` for mirror clones.

Next: Junio C Hamano
Message 1 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.