Next: , Previous: , Up: FAQ - Issues and Errors   [Contents][Index]


A.2.11 git-commit-mode isn’t used when committing from the command-line

The reason for this is that git-commit.el has not been loaded yet and/or that the server has not been started yet. These things have always already been taken care of when you commit from Magit because in order to do so, Magit has to be loaded and doing that involves loading git-commit and starting the server.

If you want to commit from the command-line, then you have to take care of these things yourself. Your init.el file should contain:

(require 'git-commit)
(server-mode)

Instead of ‘(require ’git-commit)‘ you may also use:

(load "/path/to/magit-autoloads.el")

You might want to do that because loading git-commit causes large parts of Magit to be loaded.

There are also some variations of (server-mode) that you might want to try. Personally I use:

(use-package server
  :config (or (server-running-p) (server-mode)))

Now you can use:

$ emacs&
$ EDITOR=emacsclient git commit

However you cannot use:

$ killall emacs
$ EDITOR="emacsclient --alternate-editor emacs" git commit

This will actually end up using emacs, not emacsclient. If you do this, then you can still edit the commit message but git-commit-mode won’t be used and you have to exit emacs to finish the process.

Tautology ahead. If you want to be able to use emacsclient to connect to a running emacs instance, even though no emacs instance is running, then you cannot use emacsclient directly.

Instead you have to create a script that does something like this:

Try to use emacsclient (without using --alternate-editor). If that succeeds, do nothing else. Otherwise start emacs & (and init.el must call server-start) and try to use emacsclient again.


Next: Point ends up inside invisible text when jumping to a file-visiting buffer, Previous: My Git hooks work on the command-line but not inside Magit, Up: FAQ - Issues and Errors   [Contents][Index]