In Emacs, how to inspect what has been modified in a buffer (before saving and overwriting the file)

diff()emacsfiles

In Emacs, how do I inspect what has been modified in a buffer (before saving and overwriting the file)?

(In a sense, the requested action is an analog of git status and git add -i showing what has been modified, only the comparison should be done between the buffer contents (in Emacs's memory) and the file on disk.)

Sometime, I forget what has been modified in a buffer, and would like to call a command to remind me.

Best Answer

M-xdiff-buffer-with-file

I've just found it by looking through files.el where I felt there is such a command:

View the differences between BUFFER and its associated file.