3
votes

I've started using emacs a few days ago, and I'm facing a problem when using git in the emacs shell (M-x shell). When I 'git commit' or 'git commit --amend', it opens vim to edit and save the commit message. I'm ok with that, but I can't find a way to save and exit vim, since hitting ESC does not trigger vim Normal Mode, and ESC is my emacs metakey. I tryed changing my git editor to emacs, but it doesn't work either, it seems like emacs shell cannot run emacs, and it doesn't open a new buffer like I thought it would.

emacs: Terminal type "dumb" is not powerful enough to run Emacs.

Is there a way I can use git command-line (I'd rather not have to use a git front-end client like magit, ...) with the emacs shell ?

Thanks, Robin

3
You can use <C-o> to get out of insert mode for a single command so <C-o>:wq<CR> or <C-o>:x<CR> or <C-o>ZZ should do the trick.romainl
Yep, it does. Thanksrobin seichais

3 Answers

3
votes

You can change your editor to something more simple, like nano, using

git config core.editor nano

Or you could just make it no open any editor by putting your message on the command line :

git commit --amend -m "My message"
2
votes

Posting the answer from @romainl in comment since it does what I want: <C-o> to get out of insert mode, :wq or :x and Enter.

0
votes

One other, round-about, way to do this is to use gits abiltiy to use a file as a commit message:

  1. before you commit write your commit message (in emacs) in a temporary file
  2. commit with: git commit -F temp_file_name
  3. erase the file