A repository has one million files and `git status` takes 30 seconds.
AdvancedScenarioScale, Submodules, LFS and GitHub Automation
Answer
Situation read → Git scans the tree for changes. You need to avoid full scans.
What I'd do →
git config core.fsmonitor trueandcore.untrackedCache true(built-in FSMonitor on macOS and Windows; Watchman on Linux).git update-index --index-version 4, orfeature.manyFiles=true, which also enables these.- Use sparse-checkout in cone mode and sparse index:
git sparse-checkout init --cone --sparse-index. - Time with
GIT_TRACE2_PERF=1 git status.
Why → FSMonitor reports changed paths so Git does not scan everything.
Interview tip → Microsoft built these features for the Windows repo, which is the usual example.
More on Scale, Submodules, LFS and GitHub Automation
A monorepo has 4 GB of history and developers only touch one service. How do you make their day-to-day faster?IntermediateDesigners commit PSD and video assets, and the repo keeps growing. How do you move them to Git LFS?IntermediateYour GitHub LFS bandwidth quota is exhausted and CI pulls fail. What do you do?AdvancedA repository uses a submodule. How does a developer get the right version of it?BeginnerSubmodules, subtree or a package manager for sharing code between repos?IntermediateCI cannot clone a private submodule: authentication fails in `actions/checkout`.Intermediate