brass-kazoo brass-kazoo - 1 year ago 99
Git Question

How do I make git use the editor of my choice for commits?

I would prefer to write my commit messages in

, but it is opening in

How do I configure git to always use
? Note that I want to do this globally, not just for a single project.

Answer Source

If you want to set the editor only for Git, do either (you don’t need both):

  • Set core.editor in your Git config: git config --global core.editor "vim"
  • Set the GIT_EDITOR environment variable: export GIT_EDITOR=vim

If you want to set the editor for Git and also other programs, set the standardized VISUAL and EDITOR environment variables*:

export VISUAL=vim

* Setting both is not necessarily needed, but some programs may not use the more-correct VISUAL. See VISUAL vs. EDITOR.

For Sublime Text: Add this to the .gitconfig. The --wait is important. (it allows to type text in sublime and will wait for save/close event.

    editor = 'subl' --wait

'subl' can be replaced by the full path of the executable but is usually available when correctly installed.

P.S> For using subl i.e. Sublime Text, make sure Subl is installed and set up properly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download