Skip to content
Tutorials Center
My learning

Topics

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.

Terminal
git config core.fsmonitor true
git fsmonitor--daemon status

Try it

Bash Start, query and stop the daemon

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.

Bash core.fsmonitor starts it automatically

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

Terminal
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 add each 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 inotify and has limits such as the fs.inotify.max_user_watches setting, 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 status is 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 stop and the next command restarts it.
  • Not with network drives. The daemon refuses to start on a remote file system unless fsmonitor.allowRemote is set, and missing events there can hide changes.
  • Related hook. The older fsmonitor-watchman hook integrates the external Watchman service instead.
  • Via Scalar. scalar register and scalar clone enable it for you. See scalar and core.fsmonitor.