M-x revert-buffer
but I suggest you to use magit-mode
to manage your git repos in Emacs.
For the record, I use to bind revert-buffer
to F5:
(global-set-key [f5] 'revert-buffer)
Question
At the bottom of my Emacs 23 editor, I notice that Emacs is aware that I am working in a directory that is under version control, what that version control system is, and what branch I am currently on. Pretty cool! But say I am on the master branch, and from the command line I do a git commit
, followed by a git checkout <branch>
. Emacs still shows me being on the master branch. How do I refresh Emacs so that it reflects the branch I am currently on without closing down all my buffers and restarting it?
Solution
M-x revert-buffer
but I suggest you to use magit-mode
to manage your git repos in Emacs.
For the record, I use to bind revert-buffer
to F5:
(global-set-key [f5] 'revert-buffer)
OTHER TIPS
You can revert buffer automatically by enable global-auto-revert-mode. If you want to enable it, please add following code to your configuration file.
(global-auto-revert-mode 1)
(setq auto-revert-check-vc-info t)
To add to giordano's answer, if many files, which are under git, are opened. Then open ibuffer (M-xibuffer
) mark the buffers you want to reload using m and then E followed by (revert-buffer nil t)
.