This is a quick guide for using Magit, a wonderful Git interface based in Emacs. Its base features are fairly simple, but it can be confusing if you're not already using Emacs, as I was a few months ago.
I'll explain Emacs basics in the last paragraph.
The stage / committing workflow with Magit is centered around an interactive version of
magit in a git repository, ie. when you have a file or folder open in the repo. The window that pops up is that interactive
Move the cursor onto a hunk and press Tab . This toggles display of its contents. Press s to stage, u to unstage, c for commit options, F for pulling options, and P for pushing options.
This alone, I feel, is many times faster than using
git commit, etc. directly.
Pressing Enter will visit the hunk under cursor.
Also check out other options in the "Magit" menu located in the menu bar, when you're in the Magit window.
Setting up Magit (and Emacs)
If you have an Emacs configuration already, just install Magit from MELPA and ignore this.
This will introduce Emacs package management with
use-package, in a way that I think is easier to maintain.
Edit the file
~/.emacs.d/init.el, then type this into it:
Then install Magit and set a keyboard shortcut to invoke it:
The mouse can be used for selection or moving the cursor around, like other editors. Typing something with an active selected region by default does not replace the text; to enable the expected behavior, add
(delete-selection-mode 1) to your init file. A selected region is just called a "region" in Emacs.
Arrow keys work as expected, and you can explore other more efficient movement keys in the Emacs tutorial; start it with C-h t
, or run M-x