5.3 Logging

The status buffer contains logs for the unpushed and unpulled commits, but that obviously isn’t enough. The transient prefix command magit-log, on l, features several suffix commands, which show a specific log in a separate log buffer.

Like other transient prefix commands, magit-log also features several infix arguments that can be changed before invoking one of the suffix commands. However, in the case of the log transient, these arguments may be taken from those currently in use in the current repository’s log buffer, depending on the value of magit-prefix-use-buffer-arguments (see Transient Arguments and Buffer Variables).

For information about the various arguments, see the git-log(1) manpage. The switch ++order=VALUE is converted to one of --author-date-order, --date-order, or --topo-order before being passed to git log.

The log transient also features several reflog commands. See Reflog.

l (magit-log)

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.

l l (magit-log-current)

Show log for the current branch. When HEAD is detached or with a prefix argument, show log for one or more revs read from the minibuffer.

l h (magit-log-head)

Show log for HEAD.

l u (magit-log-related)

Show log for the current branch, its upstream and its push target. When the upstream is a local branch, then also show its own upstream. When HEAD is detached, then show log for that, the previously checked out branch and its upstream and push-target.

l o (magit-log-other)

Show log for one or more revs read from the minibuffer. The user can input any revision or revisions separated by a space, or even ranges, but only branches, tags, and a representation of the commit at point are available as completion candidates.

l L (magit-log-branches)

Show log for all local branches and HEAD.

l b (magit-log-all-branches)

Show log for all local and remote branches and HEAD.

l a (magit-log-all)

Show log for all references and HEAD.

Two additional commands that show the log for the file or blob that is being visited in the current buffer exists, see Commands for Buffers Visiting Files. The command magit-cherry also shows a log, see Cherries.

5.3.1 Refreshing Logs

The transient prefix command magit-log-refresh, on L, can be used to change the log arguments used in the current buffer, without changing which log is shown. This works in dedicated log buffers, but also in the status buffer.

L (magit-log-refresh)

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.

L g (magit-log-refresh)

This suffix command sets the local log arguments for the current buffer.

L s (magit-log-set-default-arguments)

This suffix command sets the default log arguments for buffers of the same type as that of the current buffer. Other existing buffers of the same type are not affected because their local values have already been initialized.

L w (magit-log-save-default-arguments)

This suffix command sets the default log arguments for buffers of the same type as that of the current buffer, and saves the value for future sessions. Other existing buffers of the same type are not affected because their local values have already been initialized.

L L (magit-toggle-margin)

Show or hide the margin.

5.3.2 Log Buffer

L (magit-log-refresh)

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.

See Refreshing Logs.

q (magit-log-bury-buffer)

Bury the current buffer or the revision buffer in the same frame. Like magit-mode-bury-buffer (which see) but with a negative prefix argument instead bury the revision buffer, provided it is displayed in the current frame.

C-c C-b (magit-go-backward)

Move backward in current buffer’s history.

C-c C-f (magit-go-forward)

Move forward in current buffer’s history.

C-c C-n (magit-log-move-to-parent)

Move to a parent of the current commit. By default, this is the first parent, but a numeric prefix can be used to specify another parent.

j (magit-log-move-to-revision)

Read a revision and move to it in current log buffer.

If the chosen reference or revision isn’t being displayed in the current log buffer, then inform the user about that and do nothing else.

If invoked outside any log buffer, then display the log buffer of the current repository first; creating it if necessary.

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

Update the commit or diff buffer for the thing at point.

Either show the commit or stash at point in the appropriate buffer, or if that buffer is already being displayed in the current frame and contains information about that commit or stash, then instead scroll the buffer up. If there is no commit or stash at point, then prompt for a commit.

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

Update the commit or diff buffer for the thing at point.

Either show the commit or stash at point in the appropriate buffer, or if that buffer is already being displayed in the current frame and contains information about that commit or stash, then instead scroll the buffer down. If there is no commit or stash at point, then prompt for a commit.

= (magit-log-toggle-commit-limit)

Toggle the number of commits the current log buffer is limited to. If the number of commits is currently limited, then remove that limit. Otherwise set it to 256.

+ (magit-log-double-commit-limit)

Double the number of commits the current log buffer is limited to.

- (magit-log-half-commit-limit)

Half the number of commits the current log buffer is limited to.

User Option: magit-log-auto-more

Insert more log entries automatically when moving past the last entry. Only considered when moving past the last entry with magit-goto-*-section commands.

User Option: magit-log-show-refname-after-summary

Whether to show the refnames after the commit summaries. This is useful if you use really long branch names.

User Option: magit-log-show-color-graph-limit

When showing more commits than specified by this option, then the --color argument, if specified, is silently dropped. This is necessary because the ansi-color library, which is used to turn control sequences into faces, is just too slow.

User Option: magit-log-show-signatures-limit

When showing more commits than specified by this option, then the --show-signature argument, if specified, is silently dropped. This is necessary because checking the signature of a large number of commits is just too slow.

Magit displays references in logs a bit differently from how Git does it.

Local branches are blue and remote branches are green. Of course that depends on the used theme, as do the colors used for other types of references. The current branch has a box around it, as do remote branches that are their respective remote’s HEAD branch.

If a local branch and its push-target point at the same commit, then their names are combined to preserve space and to make that relationship visible. For example:

origin/feature
[green][blue-]

instead of

feature origin/feature
[blue-] [green-------]

Also note that while the transient features the --show-signature argument, that won’t actually be used when enabled, because Magit defaults to use just one line per commit. Instead the commit colorized to indicate the validity of the signed commit object, using the faces named magit-signature-* (which see).

For a description of magit-log-margin see Log Margin.

5.3.3 Log Margin

In buffers which show one or more logs, it is possible to show additional information about each commit in the margin. The options used to configure the margin are named magit-INFIX-margin, where INFIX is the same as in the respective major-mode magit-INFIX-mode. In regular log buffers that would be magit-log-margin.

User Option: magit-log-margin

This option specifies whether the margin is initially shown in Magit-Log mode buffers and how it is formatted.

The value has the form (INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH).

  • If INIT is non-nil, then the margin is shown initially.
  • STYLE controls how to format the author or committer date. It can be one of age (to show the age of the commit), age-abbreviated (to abbreviate the time unit to a character), or a string (suitable for format-time-string) to show the actual date. Option magit-log-margin-show-committer-date controls which date is being displayed.
  • WIDTH controls the width of the margin. This exists for forward compatibility and currently the value should not be changed.
  • AUTHOR controls whether the name of the author is also shown by default.
  • AUTHOR-WIDTH has to be an integer. When the name of the author is shown, then this specifies how much space is used to do so.

You can change the STYLE and AUTHOR-WIDTH of all magit-INFIX-margin options to the same values by customizing magit-log-margin before magit is loaded. If you do that, then the respective values for the other options will default to what you have set for that variable. Likewise if you set INIT in magit-log-margin to nil, then that is used in the default of all other options. But setting it to t, i.e. re-enforcing the default for that option, does not carry to other options.

User Option: magit-log-margin-show-committer-date

This option specifies whether to show the committer date in the margin. This option only controls whether the committer date is displayed instead of the author date. Whether some date is displayed in the margin and whether the margin is displayed at all is controlled by other options.

L (magit-margin-settings)

This transient prefix command binds the following suffix commands, each of which changes the appearance of the margin in some way.

In some buffers that support the margin, L is instead bound to magit-log-refresh, but that transient features the same commands, and then some other unrelated commands.

L L (magit-toggle-margin)

This command shows or hides the margin.

L l (magit-cycle-margin-style)

This command cycles the style used for the margin.

L d (magit-toggle-margin-details)

This command shows or hides details in the margin.

5.3.4 Select from Log

When the user has to select a recent commit that is reachable from HEAD, using regular completion would be inconvenient (because most humans cannot remember hashes or "HEAD~5", at least not without double checking). Instead a log buffer is used to select the commit, which has the advantage that commits are presented in order and with the commit message.

Such selection logs are used when selecting the beginning of a rebase and when selecting the commit to be squashed into.

In addition to the key bindings available in all log buffers, the following additional key bindings are available in selection log buffers:

C-c C-c (magit-log-select-pick)

Select the commit at point and act on it. Call magit-log-select-pick-function with the selected commit as argument.

C-c C-k (magit-log-select-quit)

Abort selecting a commit, don’t act on any commit.

User Option: magit-log-select-margin

This option specifies whether the margin is initially shown in Magit-Log-Select mode buffers and how it is formatted.

The value has the form (INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH).

  • If INIT is non-nil, then the margin is shown initially.
  • STYLE controls how to format the author or committer date. It can be one of age (to show the age of the commit), age-abbreviated (to abbreviate the time unit to a character), or a string (suitable for format-time-string) to show the actual date. Option magit-log-margin-show-committer-date controls which date is being displayed.
  • WIDTH controls the width of the margin. This exists for forward compatibility and currently the value should not be changed.
  • AUTHOR controls whether the name of the author is also shown by default.
  • AUTHOR-WIDTH has to be an integer. When the name of the author is shown, then this specifies how much space is used to do so.

5.3.5 Reflog

Also see the git-reflog(1) manpage.

These reflog commands are available from the log transient. See Logging.

l r (magit-reflog-current)

Display the reflog of the current branch.

l O (magit-reflog-other)

Display the reflog of a branch or another ref.

l H (magit-reflog-head)

Display the HEAD reflog.

User Option: magit-reflog-margin

This option specifies whether the margin is initially shown in Magit-Reflog mode buffers and how it is formatted.

The value has the form (INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH).

  • If INIT is non-nil, then the margin is shown initially.
  • STYLE controls how to format the author or committer date. It can be one of age (to show the age of the commit), age-abbreviated (to abbreviate the time unit to a character), or a string (suitable for format-time-string) to show the actual date. Option magit-log-margin-show-committer-date controls which date is being displayed.
  • WIDTH controls the width of the margin. This exists for forward compatibility and currently the value should not be changed.
  • AUTHOR controls whether the name of the author is also shown by default.
  • AUTHOR-WIDTH has to be an integer. When the name of the author is shown, then this specifies how much space is used to do so.

5.3.6 Cherries

Cherries are commits that haven’t been applied upstream (yet), and are usually visualized using a log. Each commit is prefixed with - if it has an equivalent in the upstream and + if it does not, i.e., if it is a cherry.

The command magit-cherry shows cherries for a single branch, but the references buffer (see References Buffer) can show cherries for multiple "upstreams" at once.

Also see the git-reflog(1) manpage.

Y (magit-cherry)

Show commits that are in a certain branch but that have not been merged in the upstream branch.

User Option: magit-cherry-margin

This option specifies whether the margin is initially shown in Magit-Cherry mode buffers and how it is formatted.

The value has the form (INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH).

  • If INIT is non-nil, then the margin is shown initially.
  • STYLE controls how to format the author or committer date. It can be one of age (to show the age of the commit), age-abbreviated (to abbreviate the time unit to a character), or a string (suitable for format-time-string) to show the actual date. Option magit-log-margin-show-committer-date controls which date is being displayed.
  • WIDTH controls the width of the margin. This exists for forward compatibility and currently the value should not be changed.
  • AUTHOR controls whether the name of the author is also shown by default.
  • AUTHOR-WIDTH has to be an integer. When the name of the author is shown, then this specifies how much space is used to do so.