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


5.9 Blaming

Also see the git-blame(1) manpage.

To start blaming use M-x in a file-visiting buffer to invoke one of the next tree commands. In a blob-visiting buffer you can also use the key bindings described below, and when Magit-File mode is enabled, then you can at least use C-c M-g to enter the blaming popup instead of having to type out the command name.

M-x magit-blame     (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 the revision before the revision that added the current line or chunk of lines.

M-x magit-blame-reverse     (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.

M-x magit-blame-popup     (magit-blame-popup)

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

The above commands are also bound in the keymaps magit-blame-mode-map and magit-blob-mode-map, and in the popup magit-file-popup. Once Magit-Blame mode is enabled in a file-visiting buffer, you can use B to show the blaming popup, b to blame recursively going backward in time, and f to blame recursively going forward in time (i.e. blame in reverse). These bindings are always available in blob-visiting buffers.

Additionally the following key bindings are available when Magit-Blame mode is 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.

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.

t     (magit-blame-toggle-headings)

This command shows or hides blame chunk headings.

User Option: magit-blame-heading-format

The format string used for blame headings.

User Option: magit-blame-time-format

The format string used for time strings in blame headings.

User Option: magit-blame-show-headings

This option controls whether blame block headings are initially shown. The headings can also be toggled locally using the command magit-blame-toggle-headings.

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

This hook is run by magit-blame-next-chunk and magit-blame-previous-chunk.


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