├── README.md ├── magit-cheatsheet.el ├── magit-cheatsheet.org └── magit-cheatsheet.html /README.md: -------------------------------------------------------------------------------- 1 | This cheatsheet is for **version 1** of Magit and many things have 2 | changed considerably in **version 2**, including the key bindings. If 3 | you are using version 2 (which you should), then instead head over to 4 | the new [homepage](http://magit.vc), which among other things features 5 | a [new manual](http://magit.vc/manual/magit) and a 6 | [semi-official refcard](http://magit.vc/manual/magit-refcard.pdf. If 7 | you are updating from version 1 to 2, then you should also read the 8 | [update instructions](http://magit.vc/manual/magit/Installation.html). 9 | 10 | Magit Cheatsheet 11 | ---------------- 12 | magit is an emacs mode for git, and is crazy awesome. I've distilled the Magit User Manual into a command-centric cheatsheet for my own purposes. 13 | 14 | The upstream magit project updates itself every so often. If you catch it before I do, please fork and patch! 15 | 16 | This project contains... 17 | 18 | 1. The master org-mode file in case you feel like wrestling with org-mode's org-export-as-html and its weird set of quasi-controls in order to update the cheatsheet. 19 | 20 | 2. The HTML output of exporting the current version of the org-mode file, so you can compare and contrast. 21 | 22 | 3. A utility .el file. In order to get org-mode to export nicely, I had to add two user variables to my .emacs, along with a macro I used to quick-replace the TD elements with the classes they need. 23 | 24 | 25 | 26 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/daemianmack/magit-cheatsheet/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 27 | 28 | -------------------------------------------------------------------------------- /magit-cheatsheet.el: -------------------------------------------------------------------------------- 1 | ;; Assign CSS during export. 2 | (setq org-export-html-style "") 26 | 27 | 28 | ;; Insert preamble pointing to the manual proper and my blogpost so 29 | ;; user can regenerate this however they like. 30 | (setq org-export-html-preamble " 31 | 32 |
This is a distillation of the Magit user 34 | manual, which has more detail than this quick cheatsheet 35 | provides. Read the user manual! Blogpost containing materials to 36 | regenerate this cheatsheet from scratch here.
37 | 38 | 39 | ") 40 | 41 | 42 | ;; search-and-replace macro to assign necessary CSS classes to the TD 43 | ;; elements after export. 44 | (fset 'classify-tds 45 | (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("^S^MD class=\"command\"^S^MD class=\"description\"^S^SCD ^?D class=\"notes\"^A^N" 0 "%d")) arg))) 46 | 47 | 48 | -------------------------------------------------------------------------------- /magit-cheatsheet.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Magit Cheatsheet 2 | #+OPTIONS: H:3 author:nil num:nil toc:t \n:t @:t ::nil |:t ^:t *:t TeX:t LaTeX:nil 3 | #+COLUMNS: %225ITEM %TAGS %PRIORITY %TODO 4 | 5 | 6 | 7 | 8 | * Buffers 9 | 10 | | M-x magit-status | Magit's status buffer | The 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. | 11 | | $ | magit-process buffer | Behind-the-scenes. Displays the git command and its output. | 12 | | g | reload status buffer | Necessary to update an existing Magit status buffer after saving a file in emacs, or after making changes to repo outside of emacs. | 13 | 14 | 15 | 16 | * Section Visibility 17 | 18 | | TAB | Toggle visibility of current section | | 19 | | S-TAB | Toggle visibility of current section and its children | | 20 | | 1,2,3,4 | Expand current section to the corresponding level of detail - 1, 2, 3 or 4 | e.g., 4 will show all detail for the current section. | 21 | | M-1,2,3,4 | Expand all sections to the corresponding level of detail - 1, 2, 3 or 4 | e.g., M-4 will show all detail for the entire buffer. | 22 | 23 | 24 | * Untracked Files 25 | 26 | | s | Add untracked file to staging area | | 27 | | i | Add file to .gitignore | | 28 | | C-u i | Prompt for file/directory to add to .gitignore | | 29 | | I | Add file to .git/info/exclude instead of .gitignore | | 30 | 31 | 32 | * Staging and Committing 33 | 34 | | s | Stage current hunk | If 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'. | 35 | | u | Unstage current hunk | As with s command, only in reverse: diff headers and regions provide a corresponding context to the unstage action. | 36 | | S | Stage all hunks | | 37 | | U | Unstage all hunks | | 38 | | k | Discard uncommitted changes | As with s command. | 39 | | c | Prepare for commit | Pops up *magit-log-edit* buffer. to allow you to enter your commit message. | 40 | | C-c C-c | Execute commit | Actually 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, | 41 | | C-c C-a | Make the next commit an amend | | 42 | 43 | 44 | * History 45 | 46 | | l | History | Shows terse history for repository. | 47 | | L | Verbose history | | 48 | | C-u l | History segment | Will prompt for beginning and end points. | 49 | | RET | Inspect commit | Shows full information for commit and move point into the new buffer. | 50 | | a | Stage current commit on your current branch | Useful to cherrypick changes while browsing an alternative branch. Cherrypicked changes need to be committed manually. | 51 | | A | Commit current commit on your current branch | As with 'a', but will automatically commit changes when there aren't any conflicts. | 52 | | C-w | Copy sha1 of current commit into kill ring | | 53 | | = | Show differences between current and marked commits | | 54 | | .. | Mark current commit | | 55 | | . | Unmark current commit if marked | | 56 | | C-u .. | Unmark marked commit from anywhere | | 57 | 58 | 59 | 60 | * Reflogs 61 | 62 | | h | Browse reflog from HEAD | Reflog buffer works just like History buffer described above. | 63 | | H | Browse reflog from chosen point | | 64 | 65 | 66 | 67 | * Diffing 68 | 69 | | d | Show changes between working tree and HEAD | | 70 | | D | Show changes between two arbitrary revisions | | 71 | | a | Apply current changes to working tree | Change-selection works as described in 'Staging and Committing' above. | 72 | | v | Apply current changes to working tree in reverse | | 73 | 74 | 75 | * Tagging 76 | 77 | | t | Make lightweight tag | | 78 | | T | Prepare annotated tag | Launches *magit-log-edit* buffer for writing annotation. | 79 | | C-c C-c | Commit annotated tag | Actually triggers annotated tag action. | 80 | 81 | 82 | 83 | * Resetting 84 | 85 | | x | Reset your current head to chosen revision | No 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. | 86 | | X | Reset working tree and staging area to most recent committed state | Destructive! Will discard all local modifications. | 87 | 88 | 89 | 90 | * Stashing 91 | 92 | | z | Create new stash | Stashes are listed in the status buffer. | 93 | | Z | Create new stash and maintain state | Leaves current changes in working tree and staging area. | 94 | | RET | View stash | | 95 | | a | Apply stash | | 96 | | A | Pop stash | | 97 | | k | Drop stash | | 98 | 99 | 100 | 101 | * Branching 102 | 103 | | b | Switch to different branch | Current branch is indicated in header of status buffer. | 104 | | B | Create and switch to new branch | | 105 | 106 | 107 | * Wazzup 108 | 109 | | w | Show summary of how other branches relate to current branch | | 110 | | i | Toggle ignore branch | | 111 | | C-u w | Show all branches including ignored ones | | 112 | 113 | * Merging 114 | | m | Initiate manual merge | Applies all changes to working area and index, without committing. | 115 | | M | Initiate automatic merge | Applies all changes to working area and index. Commits changes immediately. | 116 | 117 | * Rebasing 118 | | R | Initiate or continue a rebase | | 119 | | E | Initiate an interactive rebase | | 120 | 121 | * Rewriting 122 | | r s | Start a rewrite | | 123 | | v | Revert a given commit | | 124 | | r t | Remove bookkeeping information from buffer | | 125 | | r a | Abort rewriting | | 126 | | r f | Finish rewriting | Applies all unused commits. | 127 | | r * | Toggle the * mark on a pending commit | | 128 | | r .. | Toggle the . mark on a pending commit | | 129 | 130 | * Pushing and Pulling 131 | | P | git push | Uses default remote repository. | 132 | | C-u P | git push to specified remote repository | | 133 | | C-u C-u P | git push to specified remote as specified branch | | 134 | | f | git remote update | | 135 | | F | git pull | | 136 | 137 | * Interfacing with Subversion 138 | | N r | git svn rebase | | 139 | | N c | git svn dcommit | | 140 | -------------------------------------------------------------------------------- /magit-cheatsheet.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Magit Cheatsheet 7 | 8 | 9 | 10 | 34 | 80 | 81 | 82 | 83 |
84 |

THIS CHEATSHEET IS OBSOLETE AS OF MAGIT V2

85 |

86 | This cheatsheet is for version 1 of Magit and many things 87 | have changed considerably in version 2, including the key 88 | bindings. If you are using version 2 (which you should), then 89 | instead head over to the 90 | new homepage, which among other 91 | things features a new 92 | manual and 93 | a semi-official 94 | refcard. If you are updating from version 1 to 2, then you 95 | should also read 96 | the update 97 | instructions. 98 |

99 |
100 | 101 |
102 |

Magit Cheatsheet

103 |
104 |

Table of Contents

105 |
106 | 125 |
126 |
127 | 128 | 129 | 130 | 131 |
132 |

Buffers

133 |
134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 |
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.
164 |
165 |
166 | 167 | 168 | 169 |
170 |

Section Visibility

171 |
172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
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.
208 |
209 |
210 | 211 | 212 |
213 |

Untracked Files

214 |
215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 |
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 
251 |
252 |
253 | 254 | 255 |
256 |

Staging and Committing

257 |
258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 |
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 
318 |
319 |
320 | 321 | 322 |
323 |

History

324 |
325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 |
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 
403 |
404 |
405 | 406 | 407 | 408 |
409 |

Reflogs

410 |
411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |
hBrowse reflog from HEADReflog buffer works just like History buffer described above.
HBrowse reflog from chosen point 
435 |
436 |
437 | 438 | 439 | 440 |
441 |

Diffing

442 |
443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 |
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 
479 |
480 |
481 | 482 | 483 |
484 |

Tagging

485 |
486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 |
tMake lightweight tag 
TPrepare annotated tagLaunches magit-log-edit buffer for writing annotation.
C-c C-cCommit annotated tagActually triggers annotated tag action.
516 |
517 |
518 | 519 | 520 | 521 |
522 |

Resetting

523 |
524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 |
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.
548 |
549 |
550 | 551 | 552 | 553 |
554 |

Stashing

555 |
556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 |
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 
604 |
605 |
606 | 607 | 608 | 609 |
610 |

Branching

611 |
612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 |
bSwitch to different branchCurrent branch is indicated in header of status buffer.
BCreate and switch to new branch 
636 |
637 |
638 | 639 | 640 |
641 |

Wazzup

642 |
643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 |
wShow summary of how other branches relate to current branch 
iToggle ignore branch 
C-u wShow all branches including ignored ones 
673 |
674 |
675 | 676 |
677 |

Merging

678 |
679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 |
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.
703 |
704 |
705 | 706 |
707 |

Rebasing

708 |
709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 |
RInitiate or continue a rebase 
EInitiate an interactive rebase 
733 |
734 |
735 | 736 |
737 |

Rewriting

738 |
739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 |
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 
793 |
794 |
795 | 796 |
797 |

Pushing and Pulling

798 |
799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 |
Pgit pushUses default remote repository.
C-u Pgit push to specified remote repository 
C-u C-u Pgit push to specified remote as specified branch 
fgit remote update 
Fgit pull 
841 |
842 |
843 | 844 |
845 |

Interfacing with Subversion

846 |
847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 |
N rgit svn rebase 
N cgit svn dcommit 
871 |
872 |
873 |
874 |
875 |

Created: 2015-10-30 Fri 14:12

876 |

Emacs 24.5.1 (Org mode 8.2.10)

877 |

Validate

878 |
879 | 880 | 881 | --------------------------------------------------------------------------------