I'd like to use emacsclient as my editor in git, i.e. the core.editor setting in my .gitconfig. In my .gitconfig, I have:
...
[core]
editor = /usr/local/bin/emacsclient --tty
...
When I do something like git commit --amend, or just git commit, I get put into emacs(client) as expected, but when trying to exit with C-x C-c, I get the message:
Don’t kill this buffer #<buffer COMMIT_EDITMSG>. Instead cancel using C-c C-k
Following the suggestion to cancel above results in an obvious error from git:
error: There was a problem with the editor '/usr/local/bin/emacsclient --tty'.
Please supply the message using either -m or -F option.
What I've discovered is that using C-x # kind of works, my changes are there. However, the next time I run something like git commit --amend, I get the message in emacsclient:
Revert buffer from file /[CONTAINING FOLDER]/.git/COMMIT_EDITMSG? (yes or no)
so I'm guessing this isn't exactly the right way to exit. I've also tried C-x k, but that doesn't seem to save anything.
Looks like the buffer is using (one of the variants of)
git-commitmode.To accept the commit message use C-c C-c (control+c twice)
https://github.com/magit/magit/blob/main/lisp/git-commit.el has this commentary: