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

Re: [PATCH] remote: add --set-head option to 'git remote add'

From
Ben Knoble <ben.knoble@gmail.com>
Date
Apr 25, 2026, 17:20 UTC
Message-ID
<6F9060F0-20EB-4B60-8677-86DA2AB39B35@gmail.com>
In-Reply-To
<pull.2283.git.git.1777115978088.gitgitgadget@gmail.com>
Show 25 quoted lines
> Le 25 avr. 2026 à 07:19, Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com> a écrit :
> 
> From: Harald Nordgren <haraldnordgren@gmail.com>
> 
> Mirror the behavior 'git clone' applies to its first remote: after
> fetching, set refs/remotes/<name>/HEAD to the remote's default branch.
> 
> Equivalent to running:
> 
>    git remote add -f <name> <url>
>    git remote set-head <name> -a
> 
> The new option implies --fetch.
> 
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> ---
>    remote: add --set-head option to 'git remote add'
> 
>    When using GitHub's gh tool to fork a repo, it seems that set-head isn't
>    run on the upstream remote. So its default branch is not recorded
>    locally, meaning that 'git log fork' will not work.
> 
>    With git remote add --set-head upstream , the default branch is set in
>    the same step and things can work out of the box after a small change on
>    'gh' that I will do as a next step.
I’m not totally opposed to this convenience, but couldn’t we also just teach gh to run set-head as a second command?
(Of course, it will need a version check; if memory serves not all Git versions used in practice have this command? But I am on mobile and have not validated the history of git-remote’s sub-commands.)
Previous: Harald Nordgren via GitGitGadgetNext: Harald Nordgren
Message 2 of 6 in “remote: add --set-head option to 'git remote add'”
  1. remote: add --set-head option to 'git remote add'Harald Nordgren via GitGitGadget, Apr 25, 2026
  2. Ben KnobleApr 25, 2026
  3. ghHarald Nordgren, Apr 25, 2026
  4. Junio C HamanoApr 25, 2026
  5. Jeff KingApr 25, 2026
  6. Harald NordgrenApr 26, 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.