Subject: Re: fatal: Not a valid object name HEAD

From: Junio C Hamano <[email-masked]>
Date: Mon, 13 Jan 2025 08:30:17 -0800

"Bence Ferdinandy" <[email-masked]> writes:

> 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.