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


5.9 Blaming

Also see the git-blame(1) manpage.

To start blaming invoke the magit-file-dispatch transient prefix command by pressing C-c M-g.

The blaming suffix commands can be invoked from the dispatch transient. However if you want to set an infix argument, then you have to enter the blaming sub-transient first.

The key bindings shown below assume that you enter the dispatch transient using the default binding.

C-c M-g B     (magit-blame)

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.

Note that not all of the following suffixes are available at all times. For example if magit-blame-mode is not enabled, then the command whose purpose is to turn off that mode would not be of any use and therefore isn’t available.

C-c M-g b     (magit-blame-addition)
C-c M-g B b     (magit-blame-addition)

This command augments each line or chunk of lines in the current file-visiting 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.

C-c M-g r     (magit-blame-removal)
C-c M-g B r     (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-addition, this command can be used recursively.

C-c M-g f     (magit-blame-reverse)
C-c M-g B f     (magit-blame-reverse)

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

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

C-c M-g e     (magit-blame-echo)
C-c M-g B e     (magit-blame-echo)

This command is like magit-blame-addition 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.

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 both Magit-Blame mode and Read-Only mode are enabled.

b     (magit-blame)

See above.

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]