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


5.9 Blaming

Also see the git-blame(1) manpage.

To start blaming you can use M-x in a file-visiting buffer to invoke one of the following commands. You can also invoke these commands using the blame popup, which is available on b in file-visiting buffers that already contain blame information and, also on b, in all blob-visiting buffers. You can also enter the blame popup from the file popup, which is available on C-c M-g, provided magit-file-mode is enabled, see Minor Mode for Buffers Visiting Files.

Command: magit-blame

This command augments each line or chunk of lines in the current file- or blob-visiting buffer with information about what commits last touched these lines.

If the buffer visits a revision of that file, then history up to that revision is considered. Otherwise, the file’s full history is considered, including uncommitted changes.

If Magit-Blame mode is already turned on in the current buffer then blaming is done recursively, by visiting REVISION:FILE (using magit-find-file), where REVISION is a parent of the revision that added the current line or chunk of lines.

Command: magit-blame-echo

This command is like magit-blame except that it doesn’t turn on read-only-mode and that it initially uses the visualization style specified by option magit-blame-echo-style.

Command: magit-blame-removal

This command augments each line or chunk of lines in the current blob-visiting buffer with information about the revision that removes it. It cannot be used in file-visiting buffers.

Like magit-blame, this command can be used recursively.

Command: magit-blame-reverse

This command augments each line or chunk of lines in the current file- or blob-visiting buffer with information about the last revision in which a line still existed.

Like magit-blame, this command can be used recursively.

The following key bindings are available when Magit-Blame mode is enabled and Read-Only mode is not enabled. These commands are also available in other buffers; here only the behavior is described that is relevant in file-visiting buffers that are being blamed.

RET     (magit-show-commit)

This command shows the commit that last touched the line at point.

SPC     (magit-diff-show-or-scroll-up)

This command updates the commit buffer.

This either shows the commit that last touched the line at point in the appropriate buffer, or if that buffer is already being displayed in the current frame and if that buffer contains information about that commit, then the buffer is scrolled up instead.

DEL     (magit-diff-show-or-scroll-down)

This command updates the commit buffer.

This either shows the commit that last touched the line at point in the appropriate buffer, or if that buffer is already being displayed in the current frame and if that buffer contains information about that commit, then the buffer is scrolled down instead.

The following key bindings are available when Magit-Blame mode is enabled and Read-Only mode is not enabled.

b     (magit-blame-popup)

This prefix command shows the above suffix command along with the appropriate infix arguments in a popup buffer.

n     (magit-blame-next-chunk)

This command moves to the next chunk.

N     (magit-blame-next-chunk-same-commit)

This command moves to the next chunk from the same commit.

p     (magit-blame-previous-chunk)

This command moves to the previous chunk.

P     (magit-blame-previous-chunk-same-commit)

This command moves to the previous chunk from the same commit.

q     (magit-blame-quit)

This command turns off Magit-Blame mode. If the buffer was created during a recursive blame, then it also kills the buffer.

M-w     (magit-blame-copy-hash)

This command saves the hash of the current chunk’s commit to the kill ring.

When the region is active, the command saves the region’s content instead of the hash, like kill-ring-save would.

c     (magit-blame-cycle-style)

This command changes how blame information is visualized in the current buffer by cycling through the styles specified using the option magit-blame-styles.

Blaming is also controlled using the following options.

User Option: magit-blame-styles

This option defines a list of styles used to visualize blame information. For now see its doc-string to learn more.

User Option: magit-blame-echo-style

This option specifies the blame visualization style used by the command magit-blame-echo. This must be a symbol that is used as the identifier for one of the styles defined in magit-blame-styles.

User Option: magit-blame-time-format

This option specifies the format string used to display times when showing blame information.

User Option: magit-blame-read-only

This option controls whether blaming a buffer also makes temporarily read-only.

User Option: magit-blame-disable-modes

This option lists incompatible minor-modes that should be disabled temporarily when a buffer contains blame information. They are enabled again when the buffer no longer shows blame information.

User Option: magit-blame-goto-chunk-hook

This hook is run when moving between chunks.


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