The status buffer contains diffs for the staged and unstaged commits,
but that obviously isn’t enough. The transient prefix command
magit-diff
, on d
, features several suffix commands, which show a
specific diff in a separate diff buffer.
Like other transient prefix commands, magit-diff
also features several
infix arguments that can be changed before invoking one of the suffix
commands. However, in the case of the diff transient, these arguments may
be taken from those currently in use in the current repository’s diff
buffer, depending on the value of magit-prefix-use-buffer-arguments
(see Transient Arguments and Buffer Variables).
Also see the git-diff(1) manpage.
magit-diff
) ¶This transient prefix command binds the following suffix commands along with the appropriate infix arguments and displays them in a temporary buffer until a suffix is invoked.
magit-diff-dwim
) ¶Show changes for the thing at point.
For example, if point is on a commit, show the changes introduced by that commit. Likewise if point is on the section titled "Unstaged changes", then show those changes in a separate buffer. Generally speaking, compare the thing at point with the most logical, trivial and (in any situation) at least potentially useful other thing it could be compared to.
When the region selects commits, then compare the two commits at either end. There are different ways two commits can be compared. In the buffer showing the diff, you can control how the comparison, is done, using "D r" and "D f".
This function does not always show the changes that you might want to view in any given situation. You can think of the changes being shown as the smallest common denominator. There is no AI involved. If this command never does what you want, then ignore it, and instead use the commands that allow you to explicitly specify what you need.
magit-diff-range
) ¶Show differences between two commits.
RANGE should be a range (A..B or A…B) but can also be a single
commit. If one side of the range is omitted, then it defaults to
HEAD
. If just a commit is given, then changes in the working tree
relative to that commit are shown.
If the region is active, use the revisions on the first and last line of the region. With a prefix argument, instead of diffing the revisions, choose a revision to view changes along, starting at the common ancestor of both revisions (i.e., use a "…" range).
magit-diff-working-tree
) ¶Show changes between the current working tree and the HEAD
commit.
With a prefix argument show changes between the working tree and a
commit read from the minibuffer.
magit-diff-staged
) ¶Show changes between the index and the HEAD
commit. With a prefix
argument show changes between the index and a commit read from the
minibuffer.
magit-diff-unstaged
) ¶Show changes between the working tree and the index.
magit-diff-paths
) ¶Show changes between any two files on disk.
All of the above suffix commands update the repository’s diff buffer. The diff transient also features two commands which show differences in another buffer:
magit-show-commit
) ¶Show the commit at point. If there is no commit at point or with a prefix argument, prompt for a commit.
magit-stash-show
) ¶Show all diffs of a stash in a buffer.
Two additional commands that show the diff for the file or blob that is being visited in the current buffer exists, see Commands for Buffers Visiting Files.