When I use git checkout to change to a different state of a project with files open in emacs with different state, the files are not changed automatically. Instead on any modify attempt, emacs is asking to modify or revert etc the file. Typing r is opening current state of the file.

Is there a module to give auto change the open current buffer upon file change on isk with git checkout s?

  • What about changes you may want to keep/save?
    – Nsukami _
    Jun 21, 2015 at 17:01
  • Keep save in commit or file. Git probably already blocks you from checking out. At emacs side, it holds them in separate file I think, name starting with #.
    – sçuçu
    Jun 21, 2015 at 17:04
  • Yes, if the file has uncommitted changes, then git refuses to do the checkout. If the changes are only in the unsaved buffer then emacs refuses to revert. So the revert can only happen if it is safe to do so.
    – tarsius
    Jun 22, 2015 at 18:59

1 Answer 1


Turn on auto-revert-mode. When active the buffer will be refreshed whenever the file changes on disk (because of a git checkout for example) and you have no unsaved changes. To activate it everywhere at once, add (global-auto-revert-mode t) to you Emacs config.

  • Is there a way to enable auto-revert-mode without overwriting any unsaved changes I have in the editor? It'd be nice if the old buffer was saved somewhere.
    – byxor
    Feb 27, 2019 at 18:34
  • 1
    If you have unsaved changes, auto-revert-mode doesn't revert the buffer. The next time you save there will be warning that the file changed on disk and you can then write to another file or revert your changes as you like.
    – erikstokes
    Feb 27, 2019 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.