8.7 Common Commands
command
magit-switch-to-repository-buffer​
command
magit-switch-to-repository-buffer-other-window​
command
magit-switch-to-repository-buffer-other-frame​
command
magit-display-repository-buffer​
These commands read any existing Magit buffer that belongs to the current repository from the user and then switch to the selected buffer (without refreshing it).
The last variant uses magit-display-buffer
to do so and thus respects magit-display-buffer-function
.
These are some of the commands that can be used in all buffers whose major-modes derive from magit-mode
. There are other common commands beside the ones below, but these didn’t fit well anywhere else.
C-w
    (magit-copy-section-value
)​
This command saves the value of the current section to the kill-ring
, and, provided that the current section is a commit, branch, or tag section, it also pushes the (referenced) revision to the magit-revision-stack
.
When the current section is a branch or a tag, and a prefix argument is used, then it saves the revision at its tip to the kill-ring
instead of the reference name.
When the region is active, this command saves that to the kill-ring
, like kill-ring-save
would, instead of behaving as described above. If a prefix argument is used and the region is within a hunk, then it strips the diff marker column and keeps only either the added or removed lines, depending on the sign of the prefix argument.
M-w
    (magit-copy-buffer-revision
)​
This command saves the revision being displayed in the current buffer to the kill-ring
and also pushes it to the magit-revision-stack
. It is mainly intended for use in magit-revision-mode
buffers, the only buffers where it is always unambiguous exactly which revision should be saved.
Most other Magit buffers usually show more than one revision, in some way or another, so this command has to select one of them, and that choice might not always be the one you think would have been the best pick.
Outside of Magit M-w
and C-w
are usually bound to kill-ring-save
and kill-region
, and these commands would also be useful in Magit buffers. Therefore when the region is active, then both of these commands behave like kill-ring-save
instead of as described above.