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


5.4.2 Commands Available in Diffs

Some commands are only available if point is inside a diff.

magit-diff-visit-file and related commands visit the appropriate version of the file that the diff at point is about. Likewise magit-diff-visit-worktree-file and related commands visit the worktree version of the file that the diff at point is about. See Visiting Files and Blobs from a Diff for more information and the key bindings.

C-c C-t     (magit-diff-trace-definition)

This command shows a log for the definition at point.

User Option: magit-log-trace-definition-function

The function specfied by this option is used by magit-log-trace-definition to determine the function at point. For major-modes that have special needs, you could set the local value using the mode’s hook.

C-c C-e     (magit-diff-edit-hunk-commit)

From a hunk, this command edits the respective commit and visits the file.

First it visits the file being modified by the hunk at the correct location using magit-diff-visit-file. This actually visits a blob. When point is on a diff header, not within an individual hunk, then this visits the blob the first hunk is about.

Then it invokes magit-edit-line-commit, which uses an interactive rebase to make the commit editable, or if that is not possible because the commit is not reachable from HEAD by checking out that commit directly. This also causes the actual worktree file to be visited.

Neither the blob nor the file buffer are killed when finishing the rebase. If that is undesirable, then it might be better to use magit-rebase-edit-command instead of this command.

j     (magit-jump-to-diffstat-or-diff)

This command jumps to the diffstat or diff. When point is on a file inside the diffstat section, then jump to the respective diff section. Otherwise, jump to the diffstat section or a child thereof.

The next two commands are not specific to Magit-Diff mode (or and Magit buffer for that matter), but it might be worth pointing out that they are available here too.

SPC     (scroll-up)

This command scrolls text upward.

DEL     (scroll-down)

This command scrolls text downward.


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