When a file changes on disk while you're editing in Emacs, how to merge both sets of changes into the file?


As you're familiar with ediff you can also:

M-x ediff-current-file

Start ediff between current buffer and its file on disk. This command can be used instead of `revert-buffer'. If there is nothing to revert then this command fails.

I have both this and a custom diff-buffer-with-file variant bound to keys, as I use them quite frequently.


Currently I manually resolve the conflict as follows:

  • write-file the buffer visiting the original file to a temporary file
  • ediff-merge-files the original file and the temporary file
  • When finished, quit Ediff and confirm when it asks whether to kill buffer A and B.
  • write-file buffer B (*ediff-merge*) to the original file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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