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