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

Re: followRemoteHEAD management question

From
Jeff King <peff@peff.net>
Date
Jun 8, 2026, 23:49 UTC
Message-ID
<20260608234946.GB358144@coredump.intra.peff.net>
In-Reply-To
<DJ19CI50W6UH.17QLIBNTXBWXU@lfurio.us>
On Fri, Jun 05, 2026 at 12:31:30PM -0400, Matt Hunter wrote:
Show 6 quoted lines
> In the past, I've preferred to run 'git remote set-head <name> -d' when
> setting up a new repository, since I generally have an awareness of what
> the remote default branch is, and I don't like seeing them in branch
> listings or git-log annotations.  They are especially noisy to me if I
> have multiple remotes.  It's possible this config is ill-advised - I
> would love to be educated if so...

No, it's perfectly reasonable. Being able to refer to "origin" to mean "origin/HEAD" is sometimes handy, but if you don't use it, there's no reason to set up the symref in the first place.

Show 8 quoted lines
> However, since b7f7d16562c3 (fetch: add configuration for set_head
> behaviour), these changes are undone by every 'git fetch'.
> 
> The topic mentioned above (merged in a1f34d595503) adds a new
> configuration key 'remote.<name>.followRemoteHEAD'.  I'm assuming that
> the intended use for followRemoteHEAD is really only in local /
> per-repository config, since trying to apply it to my personal
> .gitconfig has some odd behavior.

I think this is a gap in the new feature's implementation. It added per-remote config, but there is no global config to fall back to (e.g., the way that remote.*.prune falls back to fetch.prune). There should be a fetch.followRemoteHEAD option (or perhaps remote.followRemoteHEAD).

Show 7 quoted lines
> The <name> in the key template does not accept a wildcard, so I must
> list out each of the common remote names I use across different
> repositories.  Since many of my repos don't actually have remotes
> established for all of these names, they pick up a kind of half-baked
> definition for each of them as git performs its config parsing.  For
> instance, a name will appear under 'git remote -v', but it won't
> have any actual properties configured.

Yes, this is a common problem with the remote-config namespace. Defining _any_ key makes the remote "exist", even without a defined url, but that isn't usually the intent. But we can't distinguish that from the case where you really do want to define a remote without a url (in which case the url is the name of the remote).

Show 8 quoted lines
> Is there another solution in place I've missed?  If not, would there be
> any opposition to a new key like 'remote.followRemoteHEAD' which serves
> to provide a default value for any remote that doesn't have its own
> 'remote.<name>.followRemoteHEAD' key?
> 
> I've started scouting out changes to make for such a patch.  It's not
> ready yet, but I figured I would throw this question out in case an easy
> answer can save the effort.

I think you are on the right track. I can see arguments for or against putting it in fetch.* or remote.*, so you'll have to pick one. ;)

-Peff
Previous: Matt HunterNext: Matt Hunter
Message 2 of 38 in “followRemoteHEAD management question”
  1. Matt HunterJun 5, 2026
  2. Jeff KingJun 8, 2026
  3. Matt HunterJun 11, 2026
  4. Jeff KingJun 11, 2026
  5. Bence FerdinandyJun 11, 2026
  6. Matt HunterJun 12, 2026
  7. 0/7 Introduce fetch.followRemoteHEAD config optionMatt Hunter, Jun 12, 2026
  8. 1/7 fetch: fixup set_head advice for warn-if-not-branchMatt Hunter, Jun 12, 2026
  9. 2/7 doc: explain fetchRemoteHEADWarn adviceMatt Hunter, Jun 12, 2026
  10. 3/7 t5510: cleanup remote in followRemoteHEAD dangling ref testMatt Hunter, Jun 12, 2026
  11. 4/7 fetch: rename function report_set_headMatt Hunter, Jun 12, 2026
  12. 5/7 fetch: refactor do_fetch handling of followRemoteHEADMatt Hunter, Jun 12, 2026
  13. 6/7 fetch: add configuration option fetch.followRemoteHEADMatt Hunter, Jun 12, 2026
  14. Matt HunterJun 12, 2026
  15. Junio C HamanoJun 12, 2026
  16. Matt HunterJun 13, 2026
  17. 7/7 fetch: fixup a misaligned commentMatt Hunter, Jun 12, 2026
  18. 0/7 Introduce fetch.followRemoteHEAD config variableMatt Hunter, Jun 16, 2026
  19. 1/7 fetch: fixup set_head advice for warn-if-not-branchMatt Hunter, Jun 16, 2026
  20. 2/7 doc: explain fetchRemoteHEADWarn adviceMatt Hunter, Jun 16, 2026
  21. 3/7 t5510: cleanup remote in followRemoteHEAD dangling ref testMatt Hunter, Jun 16, 2026
  22. 4/7 fetch: rename function report_set_headMatt Hunter, Jun 16, 2026
  23. 5/7 fetch: refactor do_fetch handling of followRemoteHEADMatt Hunter, Jun 16, 2026
  24. 6/7 fetch: add configuration variable fetch.followRemoteHEADMatt Hunter, Jun 16, 2026
  25. 7/7 fetch: fixup a misaligned commentMatt Hunter, Jun 16, 2026
  26. Junio C HamanoJun 16, 2026
  27. Junio C HamanoJun 17, 2026
  28. Matt HunterJun 18, 2026
  29. Junio C HamanoJun 18, 2026
  30. 0/8 Introduce fetch.followRemoteHEAD config variableMatt Hunter, Jun 19, 2026
  31. 3/8 t5510: cleanup remote in followRemoteHEAD dangling ref testMatt Hunter, Jun 19, 2026
  32. 1/8 fetch: fixup set_head advice for warn-if-not-branchMatt Hunter, Jun 19, 2026
  33. 4/8 fetch: rename function report_set_headMatt Hunter, Jun 19, 2026
  34. 5/8 fetch: return 0 on known git_fetch_configMatt Hunter, Jun 19, 2026
  35. 2/8 doc: explain fetchRemoteHEADWarn adviceMatt Hunter, Jun 19, 2026
  36. 6/8 fetch: refactor do_fetch handling of followRemoteHEADMatt Hunter, Jun 19, 2026
  37. 7/8 fetch: add configuration variable fetch.followRemoteHEADMatt Hunter, Jun 19, 2026
  38. 8/8 fetch: fixup a misaligned commentMatt Hunter, Jun 19, 2026

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.