# Shallow-fetch proposal grows into a set of per-remote fetch settings

_Harald Nordgren's patch to stop shallow clones from fetching every branch has become a longer series adding new remote.<name>.* options and changing --refmap._

Section: Patches. Edition of 2026-12-01. Written by an AI editor from the thread "[PATCH] fetch: add config to avoid fetching every branch in shallow repo" (186 messages): https://gitlist.dev/t/66353

The thread began with a patch adding fetch.shallow, off by default. When enabled, a fetch or pull in a shallow repository that is not already scoped to specific refs would fetch only the current branch's tracked upstream. Harald Nordgren's motivation was that a plain 'git pull' in a shallow, sparsely checked-out clone of a repository with many branches can take minutes or hang.

The most recent messages show a much larger series. A new per-remote variable, remote.<name>.fetchRefmap, provides the default for --refmap in the way remote.<name>.fetch provides default refspecs. It only says where fetched refs are stored. Another new variable, remote.<name>.fetchUpstreams, makes 'git fetch <name>' without refspecs also fetch the upstream branches that local branches have on that remote. A refactoring patch pulls out the check for whether a branch builds on a remote, which previously was inlined for the current branch only.

Two patches change --refmap itself. One lets it apply to a fetch with no command-line refspecs, so the configured refspecs decide what is fetched while the refs are stored through the map. The other applies --refmap only to refspecs with an empty destination, so a refspec with its own destination is stored there and nowhere else.

On the command side, 'git remote add' gets a --limited-fetch option that sets up fetchRefmap and fetchUpstreams instead of a wildcard fetch refspec. It is rejected with -t/--track or --mirror. Another patch turns it on by default when the repository is already shallow and neither of those options is given, because adding a second remote to a shallow clone otherwise fetched every branch.

In the same thread, D. Ben Knoble described wanting refmaps so that a bare 'git push' pushes the current branch plus his notes without reconfiguring push specs. Phillip Wood, Junio C Hamano, Kristoffer Haugsbakk and Matt Hunter also took part. The excerpts do not show where reviewers stand on the expanded design.
