![]() To work around that, you can navigate into a hunk and stage (or unstage) line by line. I frequently find that a hunk is not granular enough if I want to manicure what goes into my commits. To stage or unstage you can type s or u to stage/unstage the item (be it a whole file, or just a hunk). Pressing RET will go to the file where the change is made. You can also type H to refine the hunk for additional diff highlighting. You can use + and - to enlarge or shrink each hunk and 0 to reset to the default. Staging and Unstaging, and Working with Hunks There’s also M-n and M-p that move between sibling sections, such as between each file or between each section (like staged or unstaged). That’s your bread-and-butter navigational aid the usual movement keys in Emacs still work: C-n and C-p, and so forth. Basic Navigationīeing Emacs, n and p moves between logical entries in all parts of Magit. It's a simple but powerful feature as adds immediate clarity, particularly if you stage commits by hunk or file. You can cycle through sections easily in Magit. Most tree-like sections of Magit behave this way not just on the status window. ![]() For more granular control, you can use M-1 through to M-4 for all the files and 1 to 4 for the selected section and TAB and S-TAB to cycle the current section or all sections. ![]() Using a simple system of tree-like sections, you can expand or collapse sections, files, or hunks. Not only can you stage or unstage whole files, but you can also do so with the individual hunks in a diff – even regions of text, if a hunk is not granular enough. One major benefit of using a UI to manage your git interactions is the ability to quickly browse staged and unstaged changes. There is a header containing: local and optional remote the latest tag, if any and what HEAD points at. You can also see unpulled/unpushed commits and your stashes. But unlike git status Magit summarizes more than just the staged and unstaged changes. The status window is similar to git status as it offers an overview of your repository. That’s a smart decision, as you’ll often find yourself repeating the same commands over and over and like dired, you wouldn’t ordinarily edit anything in Magit’s many buffers anyway. Magit works in much the same way as M-x dired (or indeed C-x v d, the VC Directory status window) as it prefers single-character key bindings. The first thing you’ll notice about the Magit status window is that it plays nice with your window configuration when you open it, and when you close it with q. There is a handy overview of the most recent commits unpulled and unpushed commits, if any what HEAD is pointing at and more. Magit Status Window Magit status of a git repository. Having said that, I happily mix-and-match both there are some commands I find more ergonomic. If you’re a user of Emacs’s VC – a wonderful one-size-fits-all version control abstraction layer built into Emacs – then you’ll have to learn how to operate Magit as there is little overlap in key bindings. The status window is the most common entryway into Magit, but it is not the only one. You can also type C-x p m to open a Magit status buffer in your project root, if you use that functionality in Emacs. To use Magit, type M-x magit-status or C-x M-g j. And so this tutorial sets out to help you make the transition from command line – or Emacs’s builtin VC – to Magit. ![]() Magit – unlike other user interfaces bolted on top of a command line version control system – is faithful in its adherence to git’s vocabulary and capabilities.Īlthough Magit is now firmly entrenched in Emacs canon, it’s still a complex piece of software because, well, so is git. Magit is the sweetener that masks the bitter taste you get when you have to commune through algebraic brevity with git.
0 Comments
Leave a Reply. |