Interview Prep/Git & GitHub/Repository Health, Size and Performance

`git status` takes 8–15 seconds in a large monorepo.

IntermediateTroubleshootingRepository Health, Size and Performance
Answer

Likely causes → Git is lstat()-ing hundreds of thousands of tracked files and walking huge untracked directories (node_modules, build output) on every call. Antivirus scanning on Windows makes it worse.

Diagnose →

GIT_TRACE2_PERF=1 git status 2>&1 | grep -E 'read_directory|refresh_index|preload'
git ls-files | wc -l
git status --untracked-files=no     # if this is fast, untracked scanning is the cost

Fix → Turn on the built-in file system monitor and caches:

git config core.fsmonitor true          # builtin daemon on macOS/Windows (Git 2.37+)
git config core.untrackedCache true
git config feature.manyFiles true       # index v4 + untracked cache
git update-index --index-version 4

On Linux, use Watchman with the fsmonitor-watchman hook, or reduce the tree with sparse checkout. scalar register applies all of this in one go.

Prevent → Make ignored build dirs actually ignored, and ship a repo bootstrap script that sets these configs.

All Git & GitHub questions Roadmap: Git & GitHub

More on Repository Health, Size and Performance