The 2021 solution would be to use Microsoft GCM (Git-Credential-Manager-Core), in order to cache the credentials.
It is a cross-plateform solution, which also works on Linux/Ubuntu, provided you add a credential store.
And make sure to use Git 2.34 (Q4 2021), where "git fetch --quiet
"(man) includes an optimization to avoid useless computation of info that will never be displayed.
See commit f6bb64d (30 Aug 2021) by Patrick Steinhardt (pks-t
).
(Merged by Junio C Hamano -- gitster
-- in commit 87d4aed, 10 Sep 2021)
fetch
: skip formatting updated refs with --quiet
Signed-off-by: Patrick Steinhardt
When fetching, Git will by default print a list of all updated refs in a nicely formatted table.
In order to come up with this table, Git needs to iterate refs twice: first to determine the maximum column width, and a second time to actually format these changed refs.
While this table will not be printed in case the user passes --quiet
, we still go out of our way and do all these steps.
In fact, we even do more work compared to not passing --quiet
: without the flag, we will skip all references in the column width computation which have not been updated, but if it is set we will now compute widths for all refs.
Fix this issue by completely skipping both preparation of the format and formatting data for display in case the user passes --quiet
, improving performance especially with many refs.
The following benchmark shows a nice speedup for a quiet mirror-fetch in a repository with 2.3M refs:
Benchmark #1: HEAD~: git-fetch
Time (mean ± σ): 26.929 s ± 0.145 s [User: 24.194 s, System: 4.656 s]
Range (min … max): 26.692 s … 27.068 s 5 runs
Benchmark #2: HEAD: git-fetch
Time (mean ± σ): 25.189 s ± 0.094 s [User: 22.556 s, System: 4.606 s]
Range (min … max): 25.070 s … 25.314 s 5 runs
Summary
'HEAD: git-fetch' ran
1.07 ± 0.01 times faster than 'HEAD~: git-fetch'