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
Jeff King <peff@peff.net>
Date
Apr 25, 2026, 22:06 UTC
Message-ID
<20260425220629.GA28590@coredump.intra.peff.net>
In-Reply-To
<xmqqzf2q8zxc.fsf@gitster.g>
On Sun, Apr 26, 2026 at 06:58:55AM +0900, Junio C Hamano wrote:
Show 21 quoted lines
> "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> > 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.
> 
> Should this option (and the auto mode of "git remote set-head") even
> be necessary as an extra thing that the end-user should need to be
> aware of these days?
> 
> It feels to me that the "fetch" part of "git remote add --fetch"
> command should behave in line with what "git fetch" from the remote
> does with "remote.<name>.followRemoteHEAD" configuration.
It already does, doesn't it? Doing:
  $ git init
  $ git remote add --fetch origin /path/to/some/repo
  $ git for-each-ref
shows an origin/HEAD link.

Which I think is not too surprising, as it is just calling "git fetch" under the hood.

-Peff
Previous: Junio C HamanoNext: Harald Nordgren
Message 5 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.