David Przybilla David Przybilla - 3 months ago 19
Git Question

Emacs inside Emacs: how to exit inner emacs without exiting main one

I'm moving to emacs.
I am running a zsh terminal in my emacs, and I set up my git editor as

emacs -nw

so now I'm doing a rebase on my emacs terminal, and the emacs editor is shown with the content of my commits.
My question is how to actually save + exit the emacs within this terminal?
as doing C-x C-c exits the main emacs (Closing/killing) everything

I'm slowly moving to emacs and I don't intend to use magit, so don't consider it as a solution.


You can configure core.editor in git to something like /usr/bin/emacsclient --alternate-editor /usr/bin/emacs (add -nw if you need it).

Then you just need to add to your emacs init file this:

(unless (server-running-p) (server-start)))

to start emacs server when you start emacs (unless you have another emacs running, something experienced emacs user don't usually do)

When you do a git commit or interactive rebase, a new buffer will open in your emacs. You made the changes and do C-x # (or your keybinding to server-edit) and git will continue from there.

If emacs is not already running, the --alternate-editor will take over.