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

[BUG?] Semantics of HEAD when bare cloning non-bare repositories

From
Gguillaume.yziquel@mailfence.com <guillaume.yziquel@mailfence.com>
Date
Nov 23, 2023, 12:13 UTC
Message-ID
<179a3f7b2605b295.375e54053ab898bd.31bd44aeb0344c08@hilbert>
Hi.
Observation: When git clone --bare is used on a non-bare repo, the HEAD is put in ./refs/HEAD, and conflicts with ./HEAD in the sense that they may end up decorelated over time.
Suggestion: When bare cloning on a non-bare repo, do not put the HEAD of the non-bare repo in refs/HEAD like every branch, but treat it separately: put it in ./HEAD, not ./refs/HEAD.
Context: I was setting up an alternate repository for cargo crates, which requires a git repo to hold the index. So I wrote my config.json in a non-bare git repo, and "deployed" as a bare repo by git clone --bare. This created a ./refs/HEAD. However, the cargo crates repository I deployed (ktra) also updated the HEAD of that repo whenever I published private crates on it. So HEAD and refs/HEAD were not in sync. And, in the end, these got unsynchronised and I could not perform cargo fetch or cargo build with this alternate repo.
Ratonale: HEAD is just not a normal branch, semantically. It is what you have at the tip of your fingers in the shell with non-bare git repos. Treating as "just as all other branches" may be programatically convenient, but, in the end, it bypasses the fact that it just is not quite a normal branch. As the problem I experienced highlights. Which is why I would argue in favour of a distinguished treatment of HEADs when bare cloning a non-bare repo.
Best regards,
Guillaume Yziquel.
Next: Jeff King
Message 1 of 2 in “[BUG?] Semantics of HEAD when bare cloning non-bare repositories”
  1. guillaume.yziquel@mailfence.comNov 23, 2023
  2. Jeff KingNov 27, 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.