From: Jeff King <peff@peff.net>
To: Shibo Xia <sbxia25@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: How should submodules use different sshCommand during initial update?
Date: Tue, 14 Apr 2026 02:15:58 -0400 [thread overview]
Message-ID: <20260414061558.GA2902306@coredump.intra.peff.net> (raw)
In-Reply-To: <CAAC4ekquR+eCxTWifOR-X5hgd+rSen8eAUy8cxukouUE57xaoA@mail.gmail.com>
On Tue, Apr 14, 2026 at 09:28:20AM +0800, Shibo Xia wrote:
> My concern is that this still solves the problem indirectly through URL
> rewriting / SSH host aliasing, rather than allowing the submodule's SSH
> behavior itself to be configured more directly.
>
> So I think this answers the practical "how can this be done today?" part,
> but I am still wondering whether there is a reason Git should not support a
> more direct per-submodule sshCommand-style configuration.
For arbitrary per-submodule config, I can think of two approaches:
One is conditional includeIf directives in your ~/.gitconfig, matching
based on the submodule names. Like:
# replace PARENT and SUBMODULE with your filesystem names
[includeIf "gitdir:**/PARENT/.git/modules/SUBMODULE"]
path = .gitconfig-submodule
and then in ~/.gitconfig-submodule, you'd have:
[core]
sshCommand = whatever
This works, but it's kind of gross, as it depends on the module naming
scheme (and isn't there a proposal to make these more opaque? I didn't
follow it). And of course you're not actually putting the config in the
submodule, but rather polluting your user-level config with it (which
might or might not be preferable, depending on what you're trying to
configure).
The second thought is that we faced the same problem with "git clone"
itself: you might want to tweak some config after the repo is
initialized but before we fetch anything. We added the "clone -c" option
for that. It would seem reasonable to me to have a similar option that
is passed along to git-clone under the hood. We already have ways to
pass through options like --single-branch for the same reason.
And then presumably you could do:
git submodule update --init -c core.sshCommand=whatever
In the meantime, as a workaround I suspect you could do it in two steps,
like:
# set it for the initial clone; this is using the one-shot "git -c",
# not "clone -c" that will actually save the result in the
# new repo
git -c core.sshCommand=whatever submodule update --init
# and then save it for subsequent fetches
git submodule foreach 'git config core.sshCommand whatever'
It's rather unwieldy. And I think gets weird if you want to cover only a
subset of paths, as it doesn't look like "submodule foreach" allows
that. So you might be stuck with:
git -c core.sshCommand=whatever submodule update --init some-path
git -C .git/modules/some-path config core.sshCommand whatever
which is back to being overly intimate with the filesystem layout. There
might be a better way to do a per-module command. I don't really use
submodules myself.
-Peff
next prev parent reply other threads:[~2026-04-14 6:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 15:45 How should submodules use different sshCommand during initial update? Shibo Xia
2026-04-13 16:02 ` Junio C Hamano
2026-04-14 1:28 ` Shibo Xia
2026-04-14 6:15 ` Jeff King [this message]
2026-04-14 7:25 ` Shibo Xia
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=20260414061558.GA2902306@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbxia25@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox