Hacker News new | past | comments | ask | show | jobs | submit login
Using Emacs and Git with Magit 2.1 (lwn.net)
143 points by ScottWRobinson on July 12, 2015 | hide | past | favorite | 29 comments



Magit is so good, I nearly forgot how to use git commands anymore.

Navigation is intuitive, diffs are great, discarding and commiting hunks is superb, and it's snappy. It's really an outstanding interface for git!


> I nearly forgot how to use git commands anymore

This is my one fear. I am however willing to put up with this decay given the increase in productivity. It's up there with org-mode as an emacs feature.


After more than two years using Magit, I can only think of one instance when I didn't recall a git command when I needed it. It took about 5s of googling to find.

You can always see what command Magit is running behind the scenes by hitting `$`, in case you're curious -- I've learned a few things this way.


Yes I agree and the mappings are largely one to one. As you say magit-process with $ is great.

Next up to play with: whazzup.


Going to give it a try. The git command line is so arcane I can't remember it anyway, so this could only be an improvement.


It won't save you from having to understand git, but it will make life quicker.


For anyone who loves Magit as much as me there's a donations page http://magit.vc/donations.html


I appreciate how Magit isn't something that takes away from the git experience by holding your hands like a GUI might. Magit is just an efficient interface that in the end is just like using standard git in the command line.


As someone coming from a different discipline, git is tricky. Why would you not want to take away from that tricky experience by having a GUI? I understand the power of git, but it's really hard to use coming from a user's perspective, especially if you're working in less command-liney languages. I'd love to have a gui for git!


I just switched from command-line foo to magit today (export GIT_EDITOR=emacsclient) by accident, and I'm very surprised how much easier it is now to solve complicated rebase scenarios. I'm a very sceptical emacs user, who prefers the terminal over M-x shell and friends.

Once I got used to the few keys, it is much better than anything else I saw before, and much faster than doing it manually.

Moving picks up or down with one key, killing it, fixup, squash, inspection, ... all with one key.


i wanted a terminal in emacs that was as standard as possible and created 'sane-term'. Just ansi-term with a couple useful features. Sorry for the plug


Just tried it, it's awesome. It could persuade me. Everything just works naturally.


I have used many Git UIs over the years, and Magit is the first one that lets me work with greater speed and safety than just using the command line.


Magit is love. Magit is life. If you're an emacs and git user but don't use magit, it's a big, big waste of the powers of emacs.


Anyone able to help me out here? How do you get it to install? I tried the Melpa instructions and added the following to my .emacs:

  (require 'package) ;; You might already have this line
  (add-to-list 'package-archives
               '("melpa" . "http://melpa.org/packages/"))
  (when (< emacs-major-version 24)
    ;; For important compatibility libraries like cl-lib
    (add-to-list 'package-archives '("gnu" .   "http://elpa.gnu.org/packages/")))
  (package-initialize) ;; You might already have this line
I bounced emacs, it seemed to come back up okay. But (emacs 24.5.1 OSX) when I type "M-x package-install" it claims magit [No Match]

I use emacs- but I don't tend to customize it much.


The following works pretty well.

(defvar packages '(pkg1 pkg2 magit))

(require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)

(package-initialize) (package-refresh-contents)

(dolist (p packages) (when (not (package-installed-p p)) (package-install p)))


Try "M-x package-list-packages" to see a list and then find it. If it's not there then your package setup is incorrect.


That did it, thank you.


M-x package-refresh-contents

do this periodically to get your list updated w/ new packages and the latest releases.


Emacs is an awesome tool, but vanilla emacs is only ok.

I highly recommend that you take a couple of days or so and try playing around with packages that apply to your use. That's where it really shines.


I really live having good formatting and spell check in the commit messages. It's much nicer than the `git commit -m "blah"` messages. Sure I could use another GUI, but magit is very easy when I'm already in emacs.


If you leave out -m 'blah' git uses your $EDITOR which could be vim/emacs/whatever, which of course can spell check. So that one part is not a selling point for magit.


Perhaps you do not know, but if you leave off the -m switch, git will launch $EDITOR with a commented list of files changed, where you can write your commit message.


Perhaps he did not know, but I find that a lot of developers, especially those not using GUIs, end up using -m every single time and writing poor commit messages. With Magit, at least in my experience, you are more inclined to write better commits.

If you give developers a "lazy" option, a lot will default to it, which isn't ideal. -m is an alternative for a quick commit and end up being front and center when using the CLI.


> With Magit, at least in my experience, you are more inclined to write better commits.

I have flyspell-mode enabled for git-commit-mode. Avoids embarrassing typos in my git commit log.

It's little stuff like this adding up, making Emacs too great to ever be without.


it is also harder from the CLI to stage granular changes (git add -p helps to a point).


My experience with Magit:

I played around with it, and didn't see any advantage over using git commands.

Then I tried pushing a change. I was expecting some confirmation on what refspec to use... but no! Magit pushed my change directly to refs/heads instead of refs/for, completely bypassing gerrit code review.

I got burned. That was it; I'm never using Magit again.


So you didn't read the manual or at least the help for the command you were about to use and blame magit for not doing what you expected?

As with many emacs commands you use C-u if you want to specify the refspec to push to.


Or with the new version it's `P o` (Push, other).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: