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

Re: fatal: Not a valid object name HEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 13, 2025, 16:30 UTC
Message-ID
<xmqq5xmibrs6.fsf@gitster.g>
In-Reply-To
<D705QOX6EFH7.14GKFWVVUQWH7@ferdinandy.com>
"Bence Ferdinandy" <bence@ferdinandy.com> writes:
Show 5 quoted lines
> I think the correct way to handle this would be to check if the remote has
> `mirror=true` set, and if we're running in a bare repository we should overwrite
> HEAD and if it's not a mirror we should instead set up
> `refs/remotes/nonmirrorremote/HEAD`. (I think a remote can be a mirror without
> the repository being bare, I'm not sure.)

A non-bare repository can technically be a mirror but such a thing is only useful when (1) it never fetches from anywhere afterwards, (2) it stays on a branch that never changes by convention, or (3) it stays on a detached HEAD. Otherwise "git fetch" in it would almost always fail.

Practically (1) and (2) are not all that useful---such a static checkout does not even have to be a Git repository but a tarball extract. If you overwrite HEAD upon fetch, you will render the last remaining useful usage, (3), also useless.

Thanks.
Previous: Bence FerdinandyNext: Bence Ferdinandy
Message 3 of 18 in “fatal: Not a valid object name HEAD”
  1. Christian HesseJan 11, 2025
  2. Bence FerdinandyJan 12, 2025
  3. Junio C HamanoJan 13, 2025
  4. fetch set_head: fix non-mirror remotes in bare repositoriesBence Ferdinandy, Jan 12, 2025
  5. Junio C HamanoJan 23, 2025
  6. Bence FerdinandyJan 23, 2025
  7. Eric SunshineJan 23, 2025
  8. Christian HesseJan 24, 2025
  9. Junio C HamanoJan 24, 2025
  10. Patrick SteinhardtJan 24, 2025
  11. Eric SunshineJan 24, 2025
  12. Junio C HamanoJan 24, 2025
  13. Bence FerdinandyJan 26, 2025
  14. Bence FerdinandyJan 26, 2025
  15. 1/2 fetch set_head: refactor to use remote directlyBence Ferdinandy, Jan 26, 2025
  16. 2/2 fetch set_head: fix non-mirror remotes in bare repositoriesBence Ferdinandy, Jan 26, 2025
  17. Patrick SteinhardtJan 27, 2025
  18. Junio C HamanoJan 27, 2025

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.