Function: magit-auto-revert-mode

magit-auto-revert-mode is an autoloaded, interactive and byte-compiled function defined in magit-autorevert.el.

Signature

(magit-auto-revert-mode &optional ARG)

Documentation

Toggle Magit Auto Revert mode.

If called interactively, enable Magit Auto Revert mode if ARG is positive, and disable it if ARG is zero or negative. If called from Lisp, also enable the mode if ARG is omitted or nil, and toggle it if ARG is toggle; disable the mode otherwise.

Magit Auto Revert mode is a global minor mode that reverts buffers associated with a file that is located inside a Git repository when the file changes on disk. Use auto-revert-mode(var)/auto-revert-mode(fun) to revert a particular buffer. Or use global-auto-revert-mode(var)/global-auto-revert-mode(fun) to revert all file-visiting buffers, not just those that visit a file located inside a Git repository.

This global mode works by turning on the buffer-local mode auto-revert-mode(var)/auto-revert-mode(fun) at the time a buffer is first created. The local mode is turned on if the visited file is being tracked in a Git repository at the time when the buffer is created.

If magit-auto-revert-tracked-only is non-nil (the default), then only tracked files are reverted. But if you stage a previously untracked file using magit-stage, then this mode notices that.

Unlike global-auto-revert-mode(var)/global-auto-revert-mode(fun), this mode never reverts any buffers that are not visiting files.

The behavior of this mode can be customized using the options in the autorevert and magit-autorevert groups.

This function calls the hook magit-auto-revert-mode-hook.

Like nearly every mode, this mode should be enabled or disabled by calling the respective mode function, the reason being that changing the state of a mode involves more than merely toggling a single switch, so setting the mode variable is not enough. Also, you should not use after-init-hook to disable this mode.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-autorevert.el
;;;###autoload
(define-globalized-minor-mode magit-auto-revert-mode auto-revert-mode
  magit-turn-on-auto-revert-mode-if-desired
  :package-version '(magit . "2.4.0")
  :link '(info-link "(magit)Automatic Reverting of File-Visiting Buffers")
  :group 'magit-auto-revert
  :group 'magit-essentials
  :init-value (not (or global-auto-revert-mode noninteractive))
  :initialize #'magit-auto-revert-mode--initialize)