From: Ben Knoble Date: Fri, 29 May 2026 17:56:02 GMT Subject: Re: Suggetsions for collaboration workflows in large repos Message-ID: <82F556A1-A5C6-414E-8EFB-13F83FA30E44@gmail.com> In-Reply-To: <20260529163117.z2auhbg4sdxxgmis@archP14s> > Le 29 mai 2026 à 12:47, Matthew Hughes a écrit : > > Hi, > > I'm looking for some git workflow suggestions to help cut down on unnecessary > fetching when working in a large repo with many (hundreds) of other devs and > thousands of branches. Specifically, if in this repo I use the common config to > just fetch all the remote heads: > > $ git config set remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*' > > Then I find I get a lot of noise from the all the branches being > created/updated/deleted as well as an increase in the size of my local repo due > to all the objects I need to fetch across all those branches. > > To clarify the general performance of git in this repo is reasonable (shoutout > to `scalar`) but I am interested in cutting down on this fetching since when > working in this repo I'm generally only interested in a tiny subset of all > branches: > > 1. The `main` branch (that everyone merges into) > 2. Any of _my_ branches > 3. Occasionally, one of my colleagues branches, so e.g. I can check out their > code locally to review (most reviewing I do in the web UI, this is > GitHub) > > I have a prefix for all my branches: `mhughes-`, so to sort out just the > first two points I can configure git to fetch `main` and references with that > prefix: > > $ git config set --comment 'fetch main' remote.origin.fetch '+refs/heads/main:refs/remotes/origin/main' > $ git config set --append --comment 'fetch my branches' remote.origin.fetch '+refs/heads/mhughes-*:refs/remotes/origin/mhughes-*' > > But then when I do want to check out a colleague's branch I need to explicitly > fetch the exact ref like: > > $ git fetch origin some-colleague-branch > $ git checkout FETCH_HEAD -b some-colleague-branch > > Which is ok (it's my current workflow), but it means I have to re-fetch the > exact ref if I want to bring in changes that they make after my initial fetch > > I could add an explicit fetch of their branch like: > > $ git config set --append remote.origin.fetch '+refs/heads/some-colleague-branch:refs/remotes/origin/some-colleague-branch' > > So that each `git fetch` also brings in updates to that branch, but in the > remote we delete branches once their changes are merged, so if I leave that > config I'll eventually (once they merge their change and delete the branch) run > into errors when fetching like: > > fatal: couldn't find remote ref refs/heads/some-colleague-branch > > Does anyone have suggestions to make this smoother? Or alternative workflows > for achieving this goal? I'd also be curious to hear about other approaches > people take went working in large repos with lots of other collaborators. > Or am I just using git wrong in a repo like this, and should adopt another > approach? > > I thought about doing something like tracking > `refs/heads*/some-colleague-branch` from the remote, since with the wildcard > `*` I at least won't the fatal error on the missing reference during fetch, but > that risks my config containing an ever growing list of such wildcards, or a > bunch of manual work occasionally cleaning up old ones (or maybe that could be > automated). > > Thanks, > Matt My current advice is to enable git-maintenance on such a repo, where prefetches and commit graphs and so on will give you a nice perf boost. Then I keep the default fetch all heads config and don’t mind the noise too much.