Git Reference ยท Configuration Options
core.fsmonitor setting
Reference for core.fsmonitor: use Git's built-in file-system monitor daemon or a hook such as Watchman to skip scanning unchanged files in large working trees.
Every git status has to find out which files changed. By default Git calls lstat on every tracked file and compares the result with the index, which gets slow in repositories with hundreds of thousands of files. core.fsmonitor lets Git ask a helper instead: a program that watches the file system and can say "only these paths changed since last time".
Two helpers exist. The first is Git's own daemon, git fsmonitor--daemon, enabled with core.fsmonitor=true. It runs in the background per repository and is available on Windows and macOS builds. The second is a hook: set core.fsmonitor to the path of a script (classically one that talks to Watchman). Git calls the script and trusts its answer.
git config core.fsmonitor true # built-in daemon git config core.fsmonitor /path/to/query-watchman # hook script git config core.untrackedCache true # a good companion setting git fsmonitor--daemon status # is the daemon watching this repository?
Try it
The built-in daemon is a long-running background process, so the examples here use a hook instead and show what Git passes to it.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git config core.fsmonitor <true | false | path-to-hook>
| Value | Description |
|---|---|
true |
Use the built-in daemon. Git starts it on demand and stops it with git fsmonitor--daemon stop. |
false |
Do not use a monitor (the default). |
<path> |
Executable hook. Git runs it as hook 2 <token>, where <token> identifies the previous answer (it can be empty on the very first call). It must print a new token, a NUL byte, then NUL-separated paths changed since that token. A single / means "everything may have changed". Version 1 hooks (hook 1 <timestamp>) are still accepted. |
Related commands: git fsmonitor--daemon start|stop|status|run, git update-index --[no-]fsmonitor, git ls-files -f (lower-case tag letters mark entries that the monitor declared valid).
Edge cases: if the hook fails or prints nothing sensible, Git falls back to a full scan for that run.
Usage notes
- Trust is the cost. Git skips its own checks for files the monitor did not mention, so a hook that misses changes makes
git statuslie. Answer/when unsure. - Add
core.untrackedCache(true) as well; it speeds up the search for new files, whichfsmonitordoes not replace by itself. - Disable the daemon for network drives and other volumes where change notifications are unreliable; the daemon refuses some of them.
- Per-repository daemon: each repository gets its own process.
feature.manyFilesturns on the untracked cache and index version 4 as part of a performance bundle. - Worktrees each get their own monitor.
- Clean shutdown:
git fsmonitor--daemon stopbefore deleting a repository or moving it, otherwise the daemon keeps files open (a common cause of "directory in use" on Windows). - Scalar enables the built-in monitor automatically for the repositories it registers.
- Do not combine a hook-based monitor with
core.fsmonitor=trueassumptions: the value is either a boolean or a path.