12 ms·
Magit – A Git Porcelain inside Emacs
- michaericalribo 6y agoMagit is magic: coupled with customization via elisp, it feels smooth as butter to navigate hairy rebases, commit individual lines in changed files, or jump to open a PR in a browser. One of my daily drivers for development, and a real killer extension to emacs
- globuous 6y agoI also love: - magit-blame: show the commits for each line - magit-find-file: allows you to open a file from any branch. So you can easily have the same file from two different branches opened side by side. - magit-log-buffer-file: shows the git tree with all commits that modified the file in the current buffer (which you can then navigate just like you would when doing M-x magit-status l l) And this package is pretty sweet as well: https://melpa.org/#/git-timemachine https://melpa.org/#/git-timemachine , it allows you to navigate the git tree for a given file easily.
- globular-toast 6y agomagit-blame also allows you to step back through the history for each line by repeatedly pressing b. So after a developer has run formatters for the whole codebase and "broken" git blame, you can still see the real blame by just pressing b twice.
- ruricolist 6y agoIt's not obvious from the name, but magit-log-buffer-file also lets you browse the history of just the current region.
- yxhuvud 6y agoIt exist in stock emacs as vc-region-history. Fantastic functionality.
- mplanchard 6y agoThanks for mentioning magit-find-file. I’ve been using magit recently for the ease of doing commits of smaller hunks, but I didn’t know about find-file. I was just in a situation yesterday where I could’ve used it—wound up going to look at the second version of the file in GH.
- pmoriarty 6y agoCould you elaborate on how git-timemachine is different from magit, as the latter also lets one navigate the git tree for a given file, doesn't it?
- narwally 6y agoI knew magit really was magic when all of the sudden I became the guy people went to when they needed help with with their complicated git tasks. Before magit I knew I was only scratching the surface of git's power, but could never figure out the command line interface well enough to do more than the basics. I still don't feel like I'm a git expert, but magit lets me use it like I'm one.
- cityzen 6y agoWas going to make a joke about toilets but after some research realized porcelain does refer to a toilet in this case. Learn something new every day. In case anyone is curious: But because Git was initially a toolkit for a version control system rather than a full user-friendly VCS, it has a number of subcommands that do low-level work and were designed to be chained together UNIX-style or called from scripts. These commands are generally referred to as Git’s “plumbing” commands, while the more user-friendly commands are called “porcelain” commands. https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Po...
- duncan_bayne 6y agoI have used many Git front-ends over the years, on Windows, MacOS, and Linux. Magit is the only one that I've found preferable to just using the CLI tools.
- gumby 6y agoRight on. I rarely use the command line for git any more, which was a surprise to me.
- phonebucket 6y agoI see so many emacs things that look cool. I have vim mainly customised with language servers and the like, which seems counter to vim's philisophy and closer to emacs. So I'd love to experiment with emacs properly. But it's so painful; I'm just so much faster at everything with vim. I understand there are things like evil and spacemacs to ease the transition, but every time I try them, I just come straight back to what I'm comfortable with. Is there anyone else who jumped from vim to emacs. Do you have any tips apart from perserverance?
- brainlessdev 6y agoHere's a getting-started post I wrote when I switched from Vim to Emacs. https://fnune.com/2017/12/27/making-emacs-work-like-my-vim-setup/ https://fnune.com/2017/12/27/making-emacs-work-like-my-vim-s... Since then, I'm back to using Vim. I'm planning to write about that, too...
- OrderlyTiamat 6y agoI've always been an emacs user, so no help from me I'm afraid. But I've read from other vimmers that doom emacs is a very good transition when migrating from vim to emacs, better than spacemacs. I've tried both, and I feel like doom is easier to use overall, so take that as you will. It's not bad to stick with vim either anyway, it's a great tool itself. I use vim every now and then, and I have the exact same experience of "well, if only I could just do X like in emacs, this would go way faster". In the end they're different cultures.
- amw-zero 6y agoYou just have to recognize that Lisp is the only true path, and let that guide you to salvation. That’s not even a joke. The ability to write elisp and bind it to keys is much more useful than the “text editing as programming language” paradigm of vi. Vi is the better text editor, hands down. But enacts is the better text and software environment.
- rpod 6y agoI made the jump from vim to emacs without relying on evil or spacemacs, working my way through the built-in tutorial (C-h t) and doing my own customization from the bottom up. Surprisingly, you don't need that much customization to get productive in emacs, so it's better to find out for yourself what you need. The mnemonics of the emacs keybindings are part of what makes it so special, so it didn't make much sense to me to use evil-mode. Spacemacs is another layer of abstraction which makes it easier to get started, but ultimately hinders your customizability and understanding of the text editor you are using. I know you specifically asked for tips that apart from perseverance, but I believe this is the reason I stuck with it for the past 2 years. But beware: mastering emacs is a lifelong hobby, where you sometimes sacrifice short-term productivity for long-term happiness.
- fileeditview 6y agoI always was fascinated by the power and usability of magit. However for big repositories it always was way too slow for me. At work I literally waited minutes for some screens to load. I dropped it (and Emacs) because of performance issues and now I am happily using Vim and for Git I use the cli tools as well as lazygit and tig. I am very happy with these tools.
- rpod 6y agoAre you using magit on Windows? I am experiencing the same performance issues for large repos and am really hoping to find a way to fix this.
- fileeditview 6y agoNo I used it on Linux. But I once spent a lot of time on this issue and could not resolve it. At some point I just gave up.
- silly-silly 6y agoThats interesting, I use it for linux kernel work, what part was slow ?
- trabant00 6y agoPeople who chose it over the default CLI, please give a few examples of why and how. I forced myself to only use magit for a week and it did not work for me, CLI is still faster and more flexible. Maybe a week is not enough time, maybe I'm missing something.
- roblabla 6y agoIt has saner defaults for a lot of workflows. Two small examples: stashing prompts you for a name (instead of defaulting to a useless name), and commiting will show the diff of what you're committing on the side (similar to commit -v). It also gives a rather nice in-editor workflow for adding a single hunk to the git index, which makes crafting sensible commits easier.
- clktmr 6y agoNot a Magit user, but vim-fugitive. The main reason I prefer it over the CLI is for (un)staging hunks or lines. But I still use the CLI a lot for other stuff.
- OrderlyTiamat 6y agoAre you in windows by any chance? Magit is crazy slow on windows because of it's interaction with git, which is very quick on linux. I started trying it on windows and couldn't see why people would use it, and now that I'm on linux I have no problem with it. I use both magit and git cli now. Magit is great to get an overview of the changes, the main view is very interactive which is great (e.g. chunk or even line by line staging/discarding/etc. is great) But to each their own of course.
- globular-toast 6y agoThe first thing that drew me in was how easy it is to build commits. You can stage individual files, individual hunks and even individual lines really easily. Viewing diffs has a great, keyboard-driven UI. If your cursor is on a commit (for example when you're viewing logs, but it also works in most other places where you can see commits), you can press space to view the diff, and then use space and backspace to scroll up and down in the diff. Meanwhile you can still use n and p to navigate to different diffs. It's very slick. Rebasing is really fun with magit. I actually look forward to doing a nontrivial rebase.
- globular-toast 6y agoMagit is by far the best git porcelain, although the only other option is the CLI, of course. The difference between a porcelain like magit and some other "front-end" is you are actually using git. Other front-ends hide git behind new abstractions (or rather, old abstractions, more like SVN or other centralised VCSs) and I find that users of these never really understand how git works. I've been using magit for almost my entire life with git, I don't really know how to use the CLI, but I consider myself a git expert.
- rpod 6y agoWell said. It's the reason I hate Microsoft's Team Explorer built into Visual Studio. Almost everyone on my team uses it, and as a result, nobody understands git. The number of merge commits that could have been avoided by a simple git pull --rebase...
- simias 6y agoSlightly off-topic rant: I want this "porcelain" terminology to die, not only is it redundant (what's wrong with "user interface"?) it's not even coherently used within git. So porcelain is supposed to be the opposite of the internal piping of the application, the user facing part. Fair enough. But then why does "git status" have a "--porcelain" option that's meant to generate an output for script consumption? Shouldn't that be --pipe? And yes, I do know the history of why it's that way, but the point still stands, if you need to know arcane implementation details of some command and backward hacker logic to understand what the hell this "--porcelain" flag does, then it's a bad name. Magit is a Git user interface inside Emacs.
- bondolo 6y agoAdd to that that the page failed to make any attempt define what was meant by porcelain.
- pmoriarty 6y agoI have to agree. I find the term "porcelain" annoying. But this may be due to me being older than a lot of people for whom the term was already established by the time they heard it, while for me it's a neologism. I feel the same about the term "user stories". Why can't they just call them features? There's some kind of urge people have to make up new names for old things that just reeks of sleazy marketing or hipsterism to me. But, whatever.. I think we both know we're not going to change anybody's mind.
- chj 6y agoInsanely powerful.
- dathinab 6y agoI really love the discoverability provided by the popups. Besides that it looks so good that I want to try out emacs. Currently I'm using vscode, but many (supposedly very good/main/major) plugins where not so good. Sometimes fancy looks where favored over usability. Sometimes discoverable of features was just bad and sometimes they where just buggy (like the typescript language server). Edit: just to be clear, Atom was way worse when I did use it before.
- aksell 6y agoIf you feel like trying out something quite similar to magit via a code plugin you can have a look at edamagit, it tries to be magit but in vscode. I have used both magit and edamagit, and edamgit does the job for most features I use on a day to day basis(the most important one for me is staging/un-staging/discarding hunks in a easy way), but is is noticeably slower then magit in emacs. See https://github.com/kahole/edamagit https://github.com/kahole/edamagit
- mullikine 6y agoMagit has a sub-package called Transient (also made by Jonas Bernoulli) which is what powers its UI. It's absolutely brilliant for making porcelains.
- nextos 6y agoYes, Magit's UI is fantastic. I also love Notmuch, which has a similar interface design and a really elegant architecture. Incidentally, Magit's developer is also a Notmuch contributor. Emacs ecosystem is getting really good. Org, Notmuch and Magit are fantastic for personal management.
- narwally 6y agoI'll have to take a look at that, I love magit's UI for its ease of discovery. Before magit I didn't know that 'git bisect' existed, nor how useful it was. I can think of a few other utilities that would really benefit from a similar interface. Certain use cases of org-mode come to mind. There's nearly always a way to do what I want in org, but sometimes it's a pain to figure out even simple use cases without going to the docs or a forum. It's just something that seems to go hand in hand with all really powerful tools. I may play around with writing a custom mode for my particular workflow of using org for literate programming. There are a bunch of commands I find useful, but don't use often enough to have committed to memory. I'd also love to be able to pull up a pop-up buffer, like magit's commit messages, whenever I want to edit a source block in more detail.
- d0mine 6y agoHydra can be used to create UI in emacs for hints/speed https://github.com/abo-abo/hydra https://github.com/abo-abo/hydra
- pmoriarty 6y agoWhile I absolutely adore Magit, I wonder why it doesn't just use hydra, a well established package to which Transient is very very similar.[1] Why don't these two brilliant programmers team up and make one package twice as good, instead of working on two separate packages and mostly duplicating effort? [1] - https://magit.vc/manual/transient/Comparison-With-Other-Packages.html https://magit.vc/manual/transient/Comparison-With-Other-Pack...
- nickjj 6y agoFor making commits, does anyone else still stick with using git add -p , along with the s/e options? Granted I don't use Emacs but I haven't found any plugin in any editor that gives the same confidence and flexibility as git add -p.
- nicoburns 6y agoAdvanced committing (hunk level) is the one thing I use a GUI for. Sublime merge is pretty ideal for this as it opens instantly, and you can open it from the command line with the `smerge` command.
- nickjj 6y ago> Advanced committing (hunk level) is the one thing I use a GUI for. Hunk level commits is what git add -p [s/e] lets you do. You can split hunks with s, and if you need even more fine grain control you can hit e which opens that specific hunk in your $EDITOR and then you can pick whatever you want to commit.
- nicoburns 6y agoYeah, I know you can do that. It's just that while I prefer the CLI for most tasks, I find it's much easier to do hunk selection using a GUI.
- barrkel 6y agomagit lets you stage each hunk, or if you want finer grained control, simply select the lines you want to commit or exclude and it will just stage / unstage those lines. It's better than editing a patch file; it's much better than `git add -i`.
- heavenlyblue 6y agoSublime merge looks great, but it costs quite close to what I would be paying for a full IDEA licence yearly: $100? This is ridiculous.
- mark_l_watson 6y agoI found Magic useful when working on a team for more complex git workflow. That said, almost all of my git workflow now is simple stuff and I find that setting up git aliases/abbreviations is best for me, less ceremony.
- lbj 6y agoMagit is great, Im still using Egg for most Git stuff though.
- vngzs 6y agoI truly love Emacs. Magit is part of what I see as its three "killer apps": - Magit. Best Git UI ever. The other comments in this thread discuss this, so it's probably sufficient to remark that it's the only serious Git tool competitive with Git's own CLI. Equal in power and superior in usability. - Org-mode[0]. Nothing comparable for structured text-editing. - Slime[1]. When you edit Emacs Lisp, you really want its near-perfect features around online documentation, jump-to-definition, code completion, etc. With this foundation you can understand the Emacs internals well enough to build whatever else you need. It gives you the best, most fully-featured REPL-ish workflow (C-x C-e to evaluate the current line of Emacs Lisp) within real source code files I have ever experienced. However, performance issues have kept me from going all-in on my adoption. Mostly this takes the form of long load times upon opening a new file type. Sometimes it's simply a new file, since the whole UI will block on parsing/analyzing a new source file (depending on the major mode). Guile Emacs[2] seemed like the only real contender to making this workable. But it hasn't received enough love over the last 5 years. Guile proper now supports Emacs Lisp, but the Emacs side of the equation still requires custom builds, and doesn't support many important features. More importantly, Guile ELisp is still slower than Emacs at running ELisp. The whole project is a dead ringer for high-hopes abandonware. I've moved back to Vim in the meantime, since it reliably opens quickly and never lags on key input. I use a shell for the rest. But I have tasted the fruit of what's possible with Emacs. I want it to work for me, and work for next generation of programmers now gravitating to big piles of Electron like VSCode or JetBrains IDEs with ridiculous barriers to extensibility[3]. None of the alternatives can replace the kind of tight edit/execute cycle possible in Emacs, nor the incredible discoverability afforded by a Lisp IDE. Are there other Emacs performance projects, hacks for speed gains, etc. worth following? [0]: https://orgmode.org/ https://orgmode.org/ [1]: https://common-lisp.net/project/slime/ https://common-lisp.net/project/slime/ [2]: https://emacsninja.com/posts/state-of-emacs-lisp-on-guile.html https://emacsninja.com/posts/state-of-emacs-lisp-on-guile.ht... [3]: https://www.baeldung.com/intellij-new-custom-plugin https://www.baeldung.com/intellij-new-custom-plugin
- blablablerg 6y agoggcemacs? That is the speedup everyone is talking about these days.
- robenkleene 6y agoFor people interested in magit-like features, but don’t use Emacs, I highly recommend tig (https://github.com/jonas/tig https://github.com/jonas/tig). Here’s a tweet with a quick video with me using it (https://twitter.com/robenkleene/status/1299415895262081024 https://twitter.com/robenkleene/status/1299415895262081024). It works particularly well with Vim (I prefer it to fugitive, mainly because it’s more accessible directly from the command line, so it makes a nice complement to CLI git).
- Myrmornis 6y ago(Plug) If you're interested in adding syntax-highlighting to magit, see https://github.com/dandavison/magit-delta https://github.com/dandavison/magit-delta.
- mgalgs 6y agoThis looks awesome... Have you had issues with it breaking across magit updates?
- Myrmornis 6y agoHi, thanks. No issues like that so far. All it does is add colors using overlays; so I think that the main/only scope for breakage is if those color overlays somehow interact badly with magit's use of overlays.
- steeef 6y agoI've been using a Vim clone of Magit for a while with good success: https://github.com/jreybert/vimagit https://github.com/jreybert/vimagit Not being an eMacs user, I'm not familiar with the feature differences, but the workflow of stage/commit is worth it alone.