Skip to content

Instantly share code, notes, and snippets.

@amuramatsu
Created November 25, 2022 15:31
Show Gist options
  • Save amuramatsu/2ffc4445aedc7f327115b69a541af08f to your computer and use it in GitHub Desktop.
Save amuramatsu/2ffc4445aedc7f327115b69a541af08f to your computer and use it in GitHub Desktop.

Magit v1/v3 cheatsheet

Common features

Section movement/visibility

magit v1 magit v2/3 functions
p p previous section
n n next section
P P previous sibling section
N N next sibling section
^ ^ parent section
[TAB] [TAB] toggle visibility of current section
S-[TAB] C-[TAB] cycle visibility of section and children
M-[TAB] cycle visibility of diff-related sections
S-[TAB] cycle visibility of all sections in buffer

Commons

magit v1 magit v2/3 functions
$ $ magit-process buffer
! ! running git
b b branching
B B bisecting
c c commiting
d d diffing
e e ediff DWIM
E ediff
f f fetching
F F pulling
k k kill file
l l logging
m m marging
M M remoting
o o submoduling
P P pushing
s s stage change at point
S S stage all changes in worktree
R r rebasing
? w apply patches
? W format patches
t t tagging
u u unstage change at point
U U reset index to some commit
z z stashing
E r i interacitve rebase

Status buffer

magit v1 magit v2/3 functions
SPC SPC update commit/diff buffer or scroll up
DEL DEL update commit/diff buffer or scroll down
g g refresh
G G refresh all
q q bury
L toggle margin
X x reset (soft reset)
B v y show references
y Y cherry-pick
C-c C-b move backward in buffer's history
C-c C-n move forkward in buffer's history
i i gitignore
I I gitignore locally (.git/info/exclude)
C-u i ? gitignore with prompt

Diff Buffer

magit v1 magit v2/3 functions
[RET] [RET] visit file at position
- - decrease context of diff hunks
+ + increase context of diff hunks
0 0 reset context of diff hunks
j jump to diff stat <> section
j jump to diff stat

Log buffer

magit v1 magit v2/3 functions
e + show more history
C-c C-c select commit at point and act on it
C-c C-k aborting selecting commit
. mark commit
= Show differences between current and marked commits

References Buffer(v2) / Branch manager(v1)

magit v1 magit v2/3 functions
y compare references with HEAD
d c compare references with current branch
o compare references with other branch

Blaming

magit v1 magit v2/3 functions
magit-blame-mode magit-blame display edit history of file
[RET] [RET] show the commit at point branch
[SPC] [SPC] update commit/diff buffer or scroll up
[DEL] [DEL] update commit/diff buffer or scroll down
t show or hide blame chunk heading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment