Magit keybind reference sheet

This is a reference sheet for magit. The only sane way to interact with git. This won’t be exhaustive list but it should make you pretty productive. Here are some other useful cheat sheets and guides:


:pushpin: You can get a comprehensiveness help sheet inside emacs by pressing ? inside magit

:pushpin: If the vanilla key is omitted, it’s because it’s the same as the evil key.

Entering magit

Evil Key Vannila Key Description
SPCgg C-cvg Open magit-status in current project

there is also the :magit ex command for evil users.

Leaving Magit

  • To close a buffer or window you should use q

  • To close a popup (transients) You should use C-g

In file commands

Evil Key Vanilla Key Description
SPCgs C-cvs Stage the current hunk in the current file
SPCgr C-cvr Revert the current hunk in the current file
SPCgB C-cvB Interactively blame a file

Basic interaction

Everything in the status buffer is interactive You can hit RET or TAB on almost anything in the buffer

Key Description
TAB Toggle the current heading
RET Expand an item
s Stage the current file/hunk
u Unstage the current item
S Stage all changes
U Unstage all changes
cc Commit all staged changes
ll Open up the git log

Branching

Key Description
bb Checkout branch
bc Create new branch
bx Delete branch
bs Create a new branch from the last commit

Merge and Rebase

Merge

Key Description
mm Merge another branch into the current branch
mi Merge the current branch into another branch

Rebase

Key Description
rp Rebase onto the default remote
re Rebase onto a different remote or branch

Remote

Key Description
Ma Add a remote
Mx Remove a remote
Mr rename a branch
MC Configure a remote

Fetch

Key Description
fp Fetch default remote
fe Fetch a different remote
fa Fetch all remotes

Pull

Key Description
Fp Pull the default remote
Fe Pull from a different remote

Push

Key Description
pp Push to the default remote
pe Push to a different remote

The git time machine

The git time machine allows you to quickly go through a files commits and explore changes over time interactivly

Evil Key Vanilla Key Description
SPCgt C-cvt Toggle the git time machine on the current file
C-j C-n Show the next revision
C-k C-p Show the previos revision
q Quit the time machine
11 Likes