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

From: Jeff King <[email-masked]>
Date: Sat, 25 Apr 2026 18:06:29 -0400

On Sun, Apr 26, 2026 at 06:58:55AM +0900, Junio C Hamano wrote:

> "Harald Nordgren via GitGitGadget" <[email-masked]> writes:
> 
> > From: Harald Nordgren <[email-masked]>
> >
> > 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