When emacs detects that a file was changed outside of an editing buffer.
emacs will ask:
somefilename changed in disk; really edit the buffer? (y, n, r or C-h)
(Incidentally, sometimes it happens even when there is no actual change, e.g. remote file on a server with drifted clock, but the question is interesting in all cases.)
emacs would ask:
somefilename changed in disk; really edit the buffer? (y, n, r, d or C-h)
d would show the difference between versions, e.g.
ediff-current-file which allows to walk the differences interactively.
That would be similar to what Debian package management does when it detects that a config file locally customized gets updated by a newer version of its owning package. For an example see A new version of configuration file /etc/default/grub is available, but the version installed currently has been locally modified - Unix & Linux Stack Exchange
Search before you ask
I usually find my way to solutions (e.g. emacsclient - From an external script, open file and run some simple expression whether emacs already running or not - Emacs Stack Exchange) but after searching on this I could not find any pre-existing solution.
I'd consider adjusting this myself but am not proficient enough in emacs-lisp and emacs internals.
Sketch of solution
C-gthen 'M-x ediff-current-file` does the job, at the cost of some keystrokes.
- The goal here would be to run
ediff-current-fileon one keypress at the above prompt.