Setting Up an Editor
Git needs an editor for two common tasks: writing commit messages (when you run git commit without -m) and editing interactive rebase scripts. By default Git uses vi on macOS/Linux and Notepad on Windows. If neither is what you want, tell Git which editor to use instead.
Setting the default editor
core.editor
# Visual Studio Code git config --global core.editor "code --wait" # Sublime Text git config --global core.editor "subl -n -w" # Atom git config --global core.editor "atom --wait" # JetBrains editors (e.g., WebStorm, IntelliJ) git config --global core.editor "webstorm --wait" # Neovim git config --global core.editor "nvim" # Vim git config --global core.editor "vim" # Nano (easiest if you've never used a terminal editor) git config --global core.editor "nano" # Notepad++ on Windows git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" # Plain Notepad on Windows git config --global core.editor "notepad"
The order Git uses to find an editor
Git checks, in order:
GIT_EDITORenvironment variablecore.editorfromgit configVISUALenvironment variableEDITORenvironment variableFalls back to
vi(orNotepadon Windows)
If you have EDITOR set already (many developers do, for crontab, sudoedit, etc.), you may not need to set core.editor at all — Git will find it.
Set up VS Code as the editor (most common)
VS Code is by far the most popular editor in 2025. To wire it up:
Step 1: install VS Code
# Make sure 'code' works in your terminal. # On macOS, open VS Code → Command Palette → "Shell Command: Install 'code' command in PATH" # On Linux, install the .deb / .rpm. # On Windows, the installer adds it to PATH by default. code --version
Step 2: tell Git to use it
git config --global core.editor "code --wait"
Step 3: also use VS Code as the diff/merge tool (optional)
git config --global merge.tool vscode git config --global mergetool.vscode.cmd 'code --wait --merge $REMOTE $LOCAL $BASE $MERGED' git config --global diff.tool vscode git config --global difftool.vscode.cmd 'code --wait --diff $LOCAL $REMOTE'
Testing it
Make a commit without -m
cd some-git-repo echo "test" > demo.txt git add demo.txt git commit # Your editor should open with the commit message template
The commit message template
When the editor opens for a commit, you see something like:
Commit message buffer
# Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # new file: demo.txt #
Type your message on the first line, save, and close the file. Git takes everything you wrote (minus comment lines) as the commit message.
Setting a personal commit message template
If your team uses a structured format, you can pre-populate the editor with a template.
~/.gitmessage
# <type>(<scope>): <subject> (max 50 chars) # |<-- body (max 72 chars per line) -->| # # Why? # # Refs: #issue-id
Point Git at it
git config --global commit.template ~/.gitmessage
Common problems
“The git editor opened but Git did not wait for me.” You forgot the
--waitflag. Add it.“My editor command is not found.” Open a fresh terminal so the new PATH takes effect; verify with
which code(macOS/Linux) orwhere code(Windows).“I am stuck in vi.” Press
Escthen type:wqand press Enter to save & quit, or:q!to quit without saving. Thengit config --global core.editor "nano"so it does not happen again.“Sublime never lets me commit.” Use
subl -n -w—-nopens a new window,-wblocks until close.