Slow git add . performance in large repo
- From
- Yissachar Radcliffe <yissachar@block.xyz>
- Date
- Mar 17, 2025, 18:53 UTC
- Message-ID
- <CAOHNGAW7ucD+xqvEuvq2GHMc42+WdKJX44XGguadK_y=pMf0Vg@mail.gmail.com>
We have a relatively large git repo and have noticed that `git add .` operations are slow (~1.5-2s). We have core.fsmonitor and core.untrackedCache set to true and `git status` executes in ~300ms. When I turn on trace2 I can see that almost all the time is spent in read_directo and it's visiting 26960 directories and 77989 paths.
I can use `git add <foo>` or `git add -u .` to speed things up but `git add .` is the most convenient for us. I created a small script to pipe the results of `git status` to `git add` and that runs in <500ms. This leaves me confused as to why the built-in performance is so slow.
git version is 2.49.0, mac os x 15.3