From: Junio C Hamano <gitster@pobox.com>
To: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Harald Nordgren <haraldnordgren@gmail.com>
Subject: Re: [PATCH] remote: add --set-head option to 'git remote add'
Date: Sun, 26 Apr 2026 06:58:55 +0900 [thread overview]
Message-ID: <xmqqzf2q8zxc.fsf@gitster.g> (raw)
In-Reply-To: <pull.2283.git.git.1777115978088.gitgitgadget@gmail.com> (Harald Nordgren via GitGitGadget's message of "Sat, 25 Apr 2026 11:19:38 +0000")
"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.
Of course, the current implementation may not do so, and that is why
you are sending this patch. A patch would need to plumb through the
mechanism, but I think this should be pretty much automatic without
giving more control than what the users already have.
And because remote.<name>.followRemoteHEAD that is unconfigured is
the same as setting it to "create", it means "git remote add -f"
will behave just like "git clone" would to remember the upstream
choice of which of their branches is the primary one (which is what
HEAD in the publishing repository means), unless the variable is
explicitly configured to "never".
IOW, I think this should/can be done as a bugfix, i.e.,
Even though "git clone -o <name> <URL>" does, "git remote add
--fetch <name> <URL>" does not create refs/remotes/<name>/HEAD.
Fix it by making it honor the remote.<name>.followRemoteHEAD
configuration variable, which was invented exactly for this
purpose..
or something.
next prev parent reply other threads:[~2026-04-25 21:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-25 11:19 [PATCH] remote: add --set-head option to 'git remote add' Harald Nordgren via GitGitGadget
2026-04-25 17:20 ` Ben Knoble
2026-04-25 18:07 ` gh Harald Nordgren
2026-04-25 21:58 ` Junio C Hamano [this message]
2026-04-25 22:06 ` [PATCH] remote: add --set-head option to 'git remote add' Jeff King
2026-04-26 8:21 ` Harald Nordgren
-- strict thread matches above, loose matches on Subject: below --
2026-04-26 7:07 Wrong subject line Kristoffer Haugsbakk
2026-04-26 15:15 ` [PATCH] remote: add --set-head option to 'git remote add' Harald Nordgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqzf2q8zxc.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=haraldnordgren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.