@@ -457,6 +457,66 @@ during the write may conflict with other simultaneous processes, causing
457
457
them to fail. Scripts running `status` in the background should consider
458
458
using `git --no-optional-locks status` (see linkgit:git[1] for details).
459
459
460
+ UNTRACKED FILES AND PERFORMANCE
461
+ -------------------------------
462
+
463
+ `git status` can be very slow in large worktrees if/when it
464
+ needs to search for untracked files and directories. There are
465
+ many configuration options available to speed this up by either
466
+ avoiding the work or making use of cached results from previous
467
+ Git commands. There is no single optimum set of settings right
468
+ for everyone. We'll list a summary of the relevant options to help
469
+ you, but before going into the list, you may want to run `git status`
470
+ again, because your configuration may already be caching `git status`
471
+ results, so it could be faster on subsequent runs.
472
+
473
+ * The `--untracked-files=no` flag or the
474
+ `status.showUntrackedfiles=false` config (see above for both):
475
+ indicate that `git status` should not report untracked
476
+ files. This is the fastest option. `git status` will not list
477
+ the untracked files, so you need to be careful to remember if
478
+ you create any new files and manually `git add` them.
479
+
480
+ * `advice.statusUoption=false` (see linkgit:git-config[1]):
481
+ setting this variable to `false` disables the warning message
482
+ given when enumerating untracked files takes more than 2
483
+ seconds. In a large project, it may take longer and the user
484
+ may have already accepted the trade off (e.g. using "-uno" may
485
+ not be an acceptable option for the user), in which case, there
486
+ is no point issuing the warning message, and in such a case,
487
+ disabling the warning may be the best.
488
+
489
+ * `core.untrackedCache=true` (see linkgit:git-update-index[1]):
490
+ enable the untracked cache feature and only search directories
491
+ that have been modified since the previous `git status` command.
492
+ Git remembers the set of untracked files within each directory
493
+ and assumes that if a directory has not been modified, then
494
+ the set of untracked files within has not changed. This is much
495
+ faster than enumerating the contents of every directory, but still
496
+ not without cost, because Git still has to search for the set of
497
+ modified directories. The untracked cache is stored in the
498
+ `.git/index` file. The reduced cost of searching for untracked
499
+ files is offset slightly by the increased size of the index and
500
+ the cost of keeping it up-to-date. That reduced search time is
501
+ usually worth the additional size.
502
+
503
+ * `core.untrackedCache=true` and `core.fsmonitor=true` or
504
+ `core.fsmonitor=<hook_command_pathname>` (see
505
+ linkgit:git-update-index[1]): enable both the untracked cache
506
+ and FSMonitor features and only search directories that have
507
+ been modified since the previous `git status` command. This
508
+ is faster than using just the untracked cache alone because
509
+ Git can also avoid searching for modified directories. Git
510
+ only has to enumerate the exact set of directories that have
511
+ changed recently. While the FSMonitor feature can be enabled
512
+ without the untracked cache, the benefits are greatly reduced
513
+ in that case.
514
+
515
+ Note that after you turn on the untracked cache and/or FSMonitor
516
+ features it may take a few `git status` commands for the various
517
+ caches to warm up before you see improved command times. This is
518
+ normal.
519
+
460
520
SEE ALSO
461
521
--------
462
522
linkgit:gitignore[5]
0 commit comments