Git Reference ยท Maintenance and Recovery
git fsmonitor--daemon command
Reference for git fsmonitor--daemon: start, stop and query the built-in file system monitor, enable it with core.fsmonitor, and understand its limits.
To report changes, git status must find out which files differ from the index. Without help it calls lstat on every tracked file and scans the tree for untracked ones, which takes seconds in a repository with hundreds of thousands of files. git fsmonitor--daemon is a small background process, built into Git, that asks the operating system to report file changes and remembers them. git status then asks the daemon "what changed since my last token?" and checks only those paths.
The daemon starts by itself when core.fsmonitor is true, so you rarely run it by hand. The commands below help you check or restart it.
git config core.fsmonitor true git fsmonitor--daemon status
Try 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 fsmonitor--daemon start [--ipc-threads=<n>] git fsmonitor--daemon run [--ipc-threads=<n>] git fsmonitor--daemon stop git fsmonitor--daemon status
| Subcommand | Description |
|---|---|
start |
Launch the daemon in the background and wait until it is ready. |
run |
Run the daemon in the foreground, which is handy for debugging with GIT_TRACE2. |
stop |
Ask the daemon to shut down. |
status |
Say whether a daemon is watching this working tree. |
--ipc-threads=<n> |
Number of threads that answer client requests (default 8). |
Returns: status prints fsmonitor-daemon is watching '<path>' and exits 0, or fsmonitor-daemon is not watching '<path>' and exits 1. start and stop exit 0 on success.
Settings:
| Config key | Meaning |
|---|---|
core.fsmonitor |
true uses the built-in daemon; a path names a hook script (the Watchman integration); false disables it. |
core.untrackedCache |
Works together with the monitor so untracked files need not be re-scanned. |
fsmonitor.allowRemote |
Allow the daemon on a network file system (off by default, because change notifications there are unreliable). |
fsmonitor.socketDir |
Directory for the IPC socket, needed when the working tree is on a file system without Unix sockets. |
Usage notes
- One daemon per working tree. Worktrees created with
git worktree addeach get their own daemon. Commands from any directory inside the tree find it. - Where it communicates. A Unix-domain socket (Linux, macOS) or a named pipe (Windows) inside
.git/fsmonitor--daemon/or the configured socket directory. The daemon exits when the working tree is deleted or when it cannot watch any more. - Platforms. Windows and macOS have long been supported; Linux support uses
inotifyand has limits such as thefs.inotify.max_user_watchessetting, which large trees can exceed. - Cost and benefit. The daemon uses memory and an event watch per directory. It pays off in big working trees; in tiny repositories
git statusis already instant and the extra process is just overhead. - Safety net. If the daemon is unavailable or its answer is unclear, Git falls back to scanning the whole tree, so results stay correct. If the daemon seems to miss changes,
git fsmonitor--daemon stopand the next command restarts it. - Not with network drives. The daemon refuses to start on a remote file system unless
fsmonitor.allowRemoteis set, and missing events there can hide changes. - Related hook. The older
fsmonitor-watchmanhook integrates the external Watchman service instead. - Via Scalar.
scalar registerandscalar cloneenable it for you. See scalar and core.fsmonitor.