简体   繁体   中英

What is the best way to use “git add -p” in emacs on Windows?

Problem:

  1. git add -p seems unusable in either emacs shell or eshell
  2. magit (a frequently suggested alternative to using git from the shell in emacs) sucks balls on Windows (it's horrendously slow.)
  3. Keeping a cygwin window open and using that for git add -p and then going back and forth between that and emacs is doable, but more than a little annoying.

Is there any way that under Microsoft Windows I can get either git add -p to work well in shell or eshell or alternatively get magit to be somewhat usable?

Have you tried:

% EDITOR=emacsclient git add -e <files>

and then using the diff-mode commands in your running emacs to interactively edit the hunks of the patch?

Then you will be able to split hunks within the patch at any particular line with diff-split-hunk and remove hunks entirely with diff-hunk-kill (and of course these commands are bound to shorter key sequences for quick interactive use). When you are done editting the patch, use Cx # to save it and quit the emacsclient session (so that you can go back to your shell).

(emacsclient, if you are not familiar with it, is a program that will let you open files in an already-running emacs, as long as the latter has started up a server for emacsclient to connect to; see the Mx describe-function server-start )

Note that you will probably want to customize how emacsclient interacts with git a little bit; for example, see these answers: Using ediff as git mergetool and How to set the exit status for emacsclient .

If magit is slow, that probably indicates problems with your windows git client?

I would look into that first and foremost (because git add -p really doesn't hold a candle to magit's interface, IMO).

What are the exact tools (and versions thereof) which you are using?

You should definitely check the magit issue tracker to see if there are known reasons why magit might be slow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM