4 ms·
> Why learn how to use git with Emacs/magit, vim, IntelliJ IDEA, Eclipse, Visual Studio / Code, ... when you can just master the official command line client an
by zelphirkalt 5y ago
> Why learn how to use git with Emacs/magit, vim, IntelliJ IDEA, Eclipse, Visual Studio / Code, ... when you can just master the official command line client and forget about the rest?
Because it is faster, has great visualization and most importantly magit has great fallbacks. You can still use the command line from magit! Pressing "!!" in a magit-status buffer will get you there, while still showing you all the nice info in the other buffers. I use it for "git submodule update --init --recursive" for example.
I have seen people struggling with git log and understanding which commit is on which branch and all that. Of course you can use something like "git log --decorate --graph --color --oneline --all" or even alias that. In magit I do: "mag-stat" (Emacs completes this to "magit-status") which one does usually anyway, to see where the repository is at and whether there are uncommited changes and so on. When I need the graph, I do: "mag-log" "-" "c" "b". Then I can go to any line in the graph and check it out, because it becomes the default for when I type "mag-check" (completed to magit-checkout) and press RET. On command line I would be copying commit ids and branch names and would remember to use my alias for the long git log command.
Edit: Another great feature is how easy it is to commit only some hunks, instead of everything that has changed. Commiting hunks on command line is tedious afaik. You would have to specify row numbers.
- tbabej 5y ago> Commiting hunks on command line is tedious afaik. You would have to specify row numbers. Not necessarily tedious - you can just use "git add -p" to stage hunks individually.
- rerx 5y agoIn Magit you can easily select arbitrary regions of code to stage (or chunks as you would via the command line). I haven't seen any git interface that is as intuitive for this task.
- rjzzleep 5y agoTry pressing `S` in `tig`. Works like magit but is much faster(when I say faster I'm also including interface lag). I realize that you won't switch, nor do you need to, but the general things people suggest of why magit is superior exist elsewhere as well.
- xemdetia 5y agoI actually use the git-gutter.el package alongside magit to do the arbitrary region work, and find it to fill the last gap between magit and the built-in version control commands.
- NateEag 5y ago`git add -p` is nice, but Magit's UI is superior, IMO. I don't know a way to stage individual lines from a given hunk separately in Git's interactive add, but in Magit's that's easy - just select the line you want and press s. I've even occasionally staged part of a line via selection, when I've actually had two distinct bugfixes on the same line.
- scooble 5y agoIirc you can edit the patch in git add -p. So fine editing is possible.
- I_complete_me 5y agoAs a side note, I am struggling to be comfortable with the word hunk in this context. I would automatically use the word chunk for this usage need. Magit introduced it to me and I balked at the usage. I looked up the etymology and it seems to be a totally legitimate usage - [0]- but to me the word 'hunk' immediately conjures up - as a heterosexual - attractive, sexually appealing man. [0] https://www.etymonline.com/search?q=hunk https://www.etymonline.com/search?q=hunk