This is a distillation of the Magit user manual, which has more detail than this quick cheatsheet provides. Read the user manual!

Magit Cheatsheet

Table of Contents

Buffers

M-x magit-statusMagit's status bufferThe main entry point to Magit, and the context where the commands described in this cheatsheet are meant to be executed. Probably a good idea to bind magit-status to a key.
$magit-process bufferBehind-the-scenes. Displays the git command and its output.
greload status bufferNecessary to update an existing Magit status buffer after saving a file in emacs, or after making changes to repo outside of emacs.

Section Visibility

TABToggle visibility of current section
S-TABToggle visibility of current section and its children
1,2,3,4Expand current section to the corresponding level of detail - 1, 2, 3 or 4e.g., 4 will show all detail for the current section.
M-1,2,3,4Expand all sections to the corresponding level of detail - 1, 2, 3 or 4e.g., M-4 will show all detail for the entire buffer.

Untracked Files

sAdd untracked file to staging area
iAdd file to .gitignore
C-u iPrompt for file/directory to add to .gitignore
IAdd file to .git/info/exclude instead of .gitignore

Staging and Committing

sStage current hunkIf point is in diff header, will stage all hunks belonging to current diff. If a region is active, only lines in that region will be staged. This is a distinct improvement on the conventional 'git add -p', the splitting mechanics of which are... 'imperfect'.
uUnstage current hunkAs with s command, only in reverse: diff headers and regions provide a corresponding context to the unstage action.
SStage all hunks
UUnstage all hunks
kDiscard uncommitted changesAs with s command.
cPrepare for commitPops up magit-log-edit buffer. to allow you to enter your commit message.
C-c C-cExecute commitActually triggers commit action. Fire this inside the magit-log-edit commit message buffer. To postpone the commit for later, just C-x b to a different buffer and come back to this buffer when you're ready,
C-c C-aMake the next commit an amend

History

lHistoryShows terse history for repository.
LVerbose history
C-u lHistory segmentWill prompt for beginning and end points.
RETInspect commitShows full information for commit and move point into the new buffer.
aStage current commit on your current branchUseful to cherrypick changes while browsing an alternative branch. Cherrypicked changes need to be committed manually.
ACommit current commit on your current branchAs with 'a', but will automatically commit changes when there aren't any conflicts.
C-wCopy sha1 of current commit into kill ring
=Show differences between current and marked commits
..Mark current commit
.Unmark current commit if marked
C-u ..Unmark marked commit from anywhere

Reflogs

hBrowse reflog from HEADReflog buffer works just like History buffer described above.
HBrowse reflog from chosen point

Diffing

dShow changes between working tree and HEAD
DShow changes between two arbitrary revisions
aApply current changes to working treeChange-selection works as described in 'Staging and Committing' above.
vApply current changes to working tree in reverse

Tagging

tMake lightweight tag
TPrepare annotated tagLaunches magit-log-edit buffer for writing annotation.
C-c C-cCommit annotated tagActually triggers annotated tag action.

Resetting

xReset your current head to chosen revisionNo changes will be made to working tree or staging area. Typing x while point is in a line describing a commit will offer this commit as the default revision to reset to.
XReset working tree and staging area to most recent committed stateDestructive! Will discard all local modifications.

Stashing

zCreate new stashStashes are listed in the status buffer.
ZCreate new stash and maintain stateLeaves current changes in working tree and staging area.
RETView stash
aApply stash
APop stash
kDrop stash

Branching

bSwitch to different branchCurrent branch is indicated in header of status buffer.
BCreate and switch to new branch

Wazzup

wShow summary of how other branches relate to current branch
iToggle ignore branch
C-u wShow all branches including ignored ones

Merging

mInitiate manual mergeApplies all changes to working area and index, without committing.
MInitiate automatic mergeApplies all changes to working area and index. Commits changes immediately.

Rebasing

RInitiate or continue a rebase

Rewriting

r sStart a rewrite
vRevert a given commit
r tRemove bookkeeping information from buffer
r aAbort rewriting
r fFinish rewritingApplies all unused commits.
r *Toggle the * mark on a pending commit
r ..Toggle the . mark on a pending commit

Pushing and Pulling

Pgit pushUses default remote repository.
C-u Pgit push to specified remote repository
fgit remote update
Fgit pull

Interfacing with Subversion

N rgit svn rebase
N cgit svn dcommit

Author: daemian <daemian@rodak>

Date: 2009/09/24 10:39:13