Git Reference ยท Configuration Options
core.editor setting
Reference for core.editor: which editor Git opens for commit messages, rebase todo lists and tags, how it is chosen, and how to set VS Code or Vim.
core.editor names the program Git launches whenever it needs you to write or edit text: a commit message, an annotated tag message, the todo list of git rebase -i, a merge message, or the files that git config --edit and git notes edit open. The value is a command line, so it can carry arguments.
Git chooses an editor in a fixed order, and core.editor sits in the middle. If you never set anything, Git falls back to vi.
git config --global core.editor "vim" git config --global core.editor "code --wait" # editors that return immediately need --wait git config --global core.editor "nano -w"
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git config [--global] core.editor <command>
| Name | Description |
|---|---|
<command> |
A program plus optional arguments. Git appends the path of the file to edit and runs the whole line through the shell, so quoting and paths with spaces need care. |
Precedence (first set wins): the GIT_EDITOR environment variable, then core.editor, then VISUAL, then EDITOR, then the built-in default vi. The value : (colon) means "do nothing", which is how scripts skip the editor.
Errors: if the editor exits with a non-zero status, Git aborts the operation ("error: There was a problem with the editor"). An editor that returns before you finish typing yields an empty message, and the commit stops with "Aborting commit due to empty commit message."
Usage notes
- GUI editors must wait.
code,sublandatomfork and return at once unless given--wait(-w), which makes Git read an empty file. - Windows paths: use forward slashes and quote the program, for example
"'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession". - Other settings that open the editor:
commit.verboseshows the diff inside it, andcommit.templatepre-fills it.sequence.editoroverrides the editor only for the rebase todo list. - Skip the editor for one command with
-m,-F,--no-edit, orGIT_EDITOR=:. - Terminal versus GUI:
VISUALis ignored whenTERMisdumbor unset, and ifTERMisdumband no terminal is available, Git refuses to start a terminal editor and asks you to use-m. - Which scope: this is a personal preference, so set it with
--globalrather than in a shared repository. - Comment lines: whatever the editor leaves starting with
#is removed by the default cleanup mode; seecommit.*.
Related
core.pager,git commit,git rebase,commit.*- Lessons: Setup and config, Interactive rebase