Next: , Previous: , Up: Modes and Buffers   [Contents][Index]


4.1.4 Automatic Refreshing of Magit Buffers

After running a command which may change the state of the current repository, the current Magit buffer and the corresponding status buffer are refreshed. The status buffer can be automatically refreshed whenever a buffer is saved to a file inside the respective repository by adding a hook, like so:

(with-eval-after-load 'magit-mode
  (add-hook 'after-save-hook 'magit-after-save-refresh-status t))

Automatically refreshing Magit buffers ensures that the displayed information is up-to-date most of the time but can lead to a noticeable delay in big repositories. Other Magit buffers are not refreshed to keep the delay to a minimum and also because doing so can sometimes be undesirable.

Buffers can also be refreshed explicitly, which is useful in buffers that weren’t current during the last refresh and after changes were made to the repository outside of Magit.

g     (magit-refresh)

This command refreshes the current buffer if its major mode derives from magit-mode as well as the corresponding status buffer.

If the option magit-revert-buffers calls for it, then it also reverts all unmodified buffers that visit files being tracked in the current repository.

G     (magit-refresh-all)

This command refreshes all Magit buffers belonging to the current repository and also reverts all unmodified buffers that visit files being tracked in the current repository.

The file-visiting buffers are always reverted, even if magit-revert-buffers is nil.

User Option: magit-refresh-buffer-hook

This hook is run in each Magit buffer that was refreshed during the current refresh - normally the current buffer and the status buffer.

User Option: magit-refresh-status-buffer

When this option is non-nil, then the status buffer is automatically refreshed after running git for side-effects, in addition to the current Magit buffer, which is always refreshed automatically.

Only set this to nil after exhausting all other options to improve performance.

Function: magit-after-save-refresh-status

This function is intended to be added to after-save-hook. After doing that the corresponding status buffer is refreshed whenever a buffer is saved to a file inside a repository.

Note that refreshing a Magit buffer is done by re-creating its contents from scratch, which can be slow in large repositories. If you are not satisfied with Magit’s performance, then you should obviously not add this function to that hook.


Next: , Previous: , Up: Modes and Buffers   [Contents][Index]