Next: Polymode, Previous: CSV Mode, Up: Special Packages [Index]
‘A Git Porcelain inside Emacs’
Magit is an interface to the version control system Git, implemented as an Emacs package. Magit aspires to be a complete Git porcelain; it is complete enough to allow even experienced Git users to perform almost all of their daily version control tasks directly from within Emacs.
Staging and otherwise applying changes is one of the most important features in a Git porcelain and here Magit outshines anything else, including Git itself. Git’s own staging interface (git add –patch) is so cumbersome that many users only use it in exceptional cases. In Magit staging a hunk or even just part of a hunk is as trivial as staging all changes made to a file.
The most visible part of Magit’s interface is the status buffer, which displays information about the current repository. Its content is created by running several Git commands and making their output actionable. Among other things, it displays information about the current branch, lists unpulled and unpushed changes and contains sections displaying the staged and unstaged changes. That might sound noisy, but, since sections are collapsible, it’s not.
To stage or unstage a change one places the cursor on the change and then types ‘s’ or ‘u’. The change can be a file or a hunk, or when the region is active (i.e. when there is a selection) several files or hunks, or even just part of a hunk. The change or changes that these commands — and many others — would act on are highlighted.
Magit also implements several other “apply variants” in addition to staging and unstaging. One can discard or reverse a change, or apply it to the working tree. Git’s own porcelain only supports this for staging and unstaging and you would have to do something like ‘git diff ... | ??? | git apply ...’ to discard, revert, or apply a single hunk on the command line. In fact that’s exactly what Magit does internally (which is what lead to the term “apply variants”).
Magit fully embraces Git. It exposes many advanced features using a simple but flexible interface instead of only wrapping the trivial ones like many GUI clients do. Of course Magit supports logging, cloning, pushing, and other commands that usually don’t fail in spectacular ways; but it also supports tasks that often cannot be completed in a single step. Magit fully supports tasks such as:
by not only providing a command to initiate these tasks but also by displaying context sensitive information along the way and providing commands that are useful for resolving conflicts and resuming the sequence after doing so.
Magit wraps and in many cases improves upon at least the following Git porcelain commands:
Many more Magit porcelain commands are implemented on top of Git plumbing commands.
Next: Polymode, Previous: CSV Mode, Up: Special Packages [Index]