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.