Next: , Previous: , Up: Inspecting   [Contents][Index]


5.4 Diffing

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.

d     (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.

d d     (magit-diff-dwim)

Show changes for the thing at point.

d r     (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).

d w     (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.

d s     (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.

d u     (magit-diff-unstaged)

Show changes between the working tree and the index.

d p     (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:

d c     (magit-show-commit)

Show the commit at point. If there is no commit at point or with a prefix argument, prompt for a commit.

d t     (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.


Next: , Previous: , Up: Inspecting   [Contents][Index]