Interview Prep/Git & GitHub/Scale, Submodules, LFS and GitHub Automation

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 →

  1. git config core.fsmonitor true and core.untrackedCache true (built-in FSMonitor on macOS and Windows; Watchman on Linux).
  2. git update-index --index-version 4, or feature.manyFiles=true, which also enables these.
  3. Use sparse-checkout in cone mode and sparse index: git sparse-checkout init --cone --sparse-index.
  4. 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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Scale, Submodules, LFS and GitHub Automation