├── 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 | [](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 |
126 |
127 |
128 |
129 |
130 |
131 |
132 | Buffers
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 | | M-x magit-status |
147 | Magit's status buffer |
148 | 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. |
149 |
150 |
151 |
152 | | $ |
153 | magit-process buffer |
154 | Behind-the-scenes. Displays the git command and its output. |
155 |
156 |
157 |
158 | | g |
159 | reload status buffer |
160 | Necessary to update an existing Magit status buffer after saving a file in emacs, or after making changes to repo outside of emacs. |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 | Section Visibility
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 | | TAB |
185 | Toggle visibility of current section |
186 | |
187 |
188 |
189 |
190 | | S-TAB |
191 | Toggle visibility of current section and its children |
192 | |
193 |
194 |
195 |
196 | | 1,2,3,4 |
197 | Expand current section to the corresponding level of detail - 1, 2, 3 or 4 |
198 | e.g., 4 will show all detail for the current section. |
199 |
200 |
201 |
202 | | M-1,2,3,4 |
203 | Expand all sections to the corresponding level of detail - 1, 2, 3 or 4 |
204 | e.g., M-4 will show all detail for the entire buffer. |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 | Untracked Files
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 | | s |
228 | Add untracked file to staging area |
229 | |
230 |
231 |
232 |
233 | | i |
234 | Add file to .gitignore |
235 | |
236 |
237 |
238 |
239 | | C-u i |
240 | Prompt for file/directory to add to .gitignore |
241 | |
242 |
243 |
244 |
245 | | I |
246 | Add file to .git/info/exclude instead of .gitignore |
247 | |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 | Staging and Committing
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 | | s |
271 | Stage current hunk |
272 | 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'. |
273 |
274 |
275 |
276 | | u |
277 | Unstage current hunk |
278 | As with s command, only in reverse: diff headers and regions provide a corresponding context to the unstage action. |
279 |
280 |
281 |
282 | | S |
283 | Stage all hunks |
284 | |
285 |
286 |
287 |
288 | | U |
289 | Unstage all hunks |
290 | |
291 |
292 |
293 |
294 | | k |
295 | Discard uncommitted changes |
296 | As with s command. |
297 |
298 |
299 |
300 | | c |
301 | Prepare for commit |
302 | Pops up magit-log-edit buffer. to allow you to enter your commit message. |
303 |
304 |
305 |
306 | | C-c C-c |
307 | Execute commit |
308 | 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, |
309 |
310 |
311 |
312 | | C-c C-a |
313 | Make the next commit an amend |
314 | |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 | History
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 | | l |
338 | History |
339 | Shows terse history for repository. |
340 |
341 |
342 |
343 | | L |
344 | Verbose history |
345 | |
346 |
347 |
348 |
349 | | C-u l |
350 | History segment |
351 | Will prompt for beginning and end points. |
352 |
353 |
354 |
355 | | RET |
356 | Inspect commit |
357 | Shows full information for commit and move point into the new buffer. |
358 |
359 |
360 |
361 | | a |
362 | Stage current commit on your current branch |
363 | Useful to cherrypick changes while browsing an alternative branch. Cherrypicked changes need to be committed manually. |
364 |
365 |
366 |
367 | | A |
368 | Commit current commit on your current branch |
369 | As with 'a', but will automatically commit changes when there aren't any conflicts. |
370 |
371 |
372 |
373 | | C-w |
374 | Copy sha1 of current commit into kill ring |
375 | |
376 |
377 |
378 |
379 | | = |
380 | Show differences between current and marked commits |
381 | |
382 |
383 |
384 |
385 | | .. |
386 | Mark current commit |
387 | |
388 |
389 |
390 |
391 | | . |
392 | Unmark current commit if marked |
393 | |
394 |
395 |
396 |
397 | | C-u .. |
398 | Unmark marked commit from anywhere |
399 | |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 | Reflogs
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 | | h |
424 | Browse reflog from HEAD |
425 | Reflog buffer works just like History buffer described above. |
426 |
427 |
428 |
429 | | H |
430 | Browse reflog from chosen point |
431 | |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 | Diffing
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 | | d |
456 | Show changes between working tree and HEAD |
457 | |
458 |
459 |
460 |
461 | | D |
462 | Show changes between two arbitrary revisions |
463 | |
464 |
465 |
466 |
467 | | a |
468 | Apply current changes to working tree |
469 | Change-selection works as described in 'Staging and Committing' above. |
470 |
471 |
472 |
473 | | v |
474 | Apply current changes to working tree in reverse |
475 | |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 | Tagging
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 | | t |
499 | Make lightweight tag |
500 | |
501 |
502 |
503 |
504 | | T |
505 | Prepare annotated tag |
506 | Launches magit-log-edit buffer for writing annotation. |
507 |
508 |
509 |
510 | | C-c C-c |
511 | Commit annotated tag |
512 | Actually triggers annotated tag action. |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 | Resetting
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 | | x |
537 | Reset your current head to chosen revision |
538 | 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. |
539 |
540 |
541 |
542 | | X |
543 | Reset working tree and staging area to most recent committed state |
544 | Destructive! Will discard all local modifications. |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 | Stashing
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 | | z |
569 | Create new stash |
570 | Stashes are listed in the status buffer. |
571 |
572 |
573 |
574 | | Z |
575 | Create new stash and maintain state |
576 | Leaves current changes in working tree and staging area. |
577 |
578 |
579 |
580 | | RET |
581 | View stash |
582 | |
583 |
584 |
585 |
586 | | a |
587 | Apply stash |
588 | |
589 |
590 |
591 |
592 | | A |
593 | Pop stash |
594 | |
595 |
596 |
597 |
598 | | k |
599 | Drop stash |
600 | |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 | Branching
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 | | b |
625 | Switch to different branch |
626 | Current branch is indicated in header of status buffer. |
627 |
628 |
629 |
630 | | B |
631 | Create and switch to new branch |
632 | |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 | Wazzup
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 | | w |
656 | Show summary of how other branches relate to current branch |
657 | |
658 |
659 |
660 |
661 | | i |
662 | Toggle ignore branch |
663 | |
664 |
665 |
666 |
667 | | C-u w |
668 | Show all branches including ignored ones |
669 | |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 | Merging
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 | | m |
692 | Initiate manual merge |
693 | Applies all changes to working area and index, without committing. |
694 |
695 |
696 |
697 | | M |
698 | Initiate automatic merge |
699 | Applies all changes to working area and index. Commits changes immediately. |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 | Rebasing
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 | | R |
722 | Initiate or continue a rebase |
723 | |
724 |
725 |
726 |
727 | | E |
728 | Initiate an interactive rebase |
729 | |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 | Rewriting
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 | | r s |
752 | Start a rewrite |
753 | |
754 |
755 |
756 |
757 | | v |
758 | Revert a given commit |
759 | |
760 |
761 |
762 |
763 | | r t |
764 | Remove bookkeeping information from buffer |
765 | |
766 |
767 |
768 |
769 | | r a |
770 | Abort rewriting |
771 | |
772 |
773 |
774 |
775 | | r f |
776 | Finish rewriting |
777 | Applies all unused commits. |
778 |
779 |
780 |
781 | | r * |
782 | Toggle the * mark on a pending commit |
783 | |
784 |
785 |
786 |
787 | | r .. |
788 | Toggle the . mark on a pending commit |
789 | |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 | Pushing and Pulling
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 | | P |
812 | git push |
813 | Uses default remote repository. |
814 |
815 |
816 |
817 | | C-u P |
818 | git push to specified remote repository |
819 | |
820 |
821 |
822 |
823 | | C-u C-u P |
824 | git push to specified remote as specified branch |
825 | |
826 |
827 |
828 |
829 | | f |
830 | git remote update |
831 | |
832 |
833 |
834 |
835 | | F |
836 | git pull |
837 | |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 | Interfacing with Subversion
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 | | N r |
860 | git svn rebase |
861 | |
862 |
863 |
864 |
865 | | N c |
866 | git svn dcommit |
867 | |
868 |
869 |
870 |
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 |
--------------------------------------------------------------------------------
|