Re: [PATCH] fetch: add config to avoid fetching every branch in shallow repo
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Sep 24, 2026, 17:10 UTC
- Message-ID
- <CALnO6CA5b7mpia9tkiOENdOKcOHF4errc31wuF5n5-=rrbHxVw@mail.gmail.com>
- In-Reply-To
- <xmqqbj9nagt2.fsf@gitster.g>
On Wed, Sep 23, 2026 at 3:50 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 18 quoted lines
> > "D. Ben Knoble" <ben.knoble@gmail.com> writes: > > >> $ git fetch second main:refs/remotes/second/main > > > > I've wanted something similar for notes, so allow me to interject from > > the sidelines: it would be even nicer to still have the ability to map > > fetches (so that "git fetch second main" did the right thing, creating > > The thing is, the command line > > $ git fetch second main > > has been used for the past 20 years as a "single-shot fetch" syntax > that expresses that the user does not intend to keep interacting > with the same 'main' branch or even the same 'second' repository, > and for the "single-shot fetch", it is absolutely the wrong thing to > create a remote-tracking branch.
Yes, perhaps I was a bit cavalier about that particular case; but in your other message you suggested allowing configurable refmaps, and that's what I was getting at previously without having the vocabulary for it. Thanks!
Show 21 quoted lines
> It would be even worse if we created a remote 'second' and > remote-tracking branch 'refs/remotes/second/main' when you ran > > $ git fetch https://ho.st/second main > > Having said that, I suspect that the fact that you have the > shorthand 'second' (i.e., you have "[remote "second"] url = ..." > defined) may be a good enough sign that you expect to keep > interacting with that repository, and some people might appreciate > it if > > $ git fetch second main > > created a remote-tracking branch "refs/remotes/second/main" > automatically. > > But we cannot suddenly start doing so without breaking people's > expectations, and without a good transition plan. We need at least > an escape hatch for users to say "No, this is a single-shot fetch; > do not write the object anywhere other than FETCH_HEAD as we have > always done".
So anyway, I think fetch.<remote>.refmap is the right thing here, thanks!
-- D. Ben Knoble