A tiny CLI can block your flow. This recipe enables the
codecommand in your shell and wires Git to open commit messages in VS Code the right way.
🍳 Ingredients
- VS Code installed
- Git installed
- Access to your shell (Terminal / PowerShell)
🪴 Steps
1. Understand the Problem
-
Git tries to open your editor as
code, but the VS Code CLI isn’t on yourPATHor Git isn’t told to wait for the editor to close. -
Typical error:
error: unable to start editor 'code'
2. Install the code command
Pre-check
Run
which codeIf which code prints nothing, you need to install the code command (CLI command to run VSCode)
MacOS
- In VS Code, press
cmd+shift+P→ then search for “Shell Command: Install ‘code’ command in PATH”.
This will create a symlink so that you can use “code” command from Terminal to run VS Code

- Verify:
which code # expect something like /usr/local/bin/code3. Tell Git to use VS Code (with —wait)
# Global (all repos)
git config --global core.editor "code --wait"
# or just for this repo
git config core.editor "code --wait"Question
Why
--wait? It makes Git pause until you close the editor, otherwise the commit would proceed immediately and fail.
4. Test it
which code # should print a path; if empty, add code to PATH
git config core.editor
git config --global core.editorValidation checklist
which codeprints a pathgit config --global core.editorshowscode --waitgit commit --amendopens VS Code to edit the messagegit commit --amend --no-editsucceeds without opening an editor
🌿 Notes
Remote/SSH servers: GUI apps can’t open. Use a terminal editor there:
git config core.editor "vim" # or "vi" or "nano"🍵 Closing Thought
A single flag and a CLI on your PATH can turn a blocking error into a smooth commit flow.