A tiny CLI can block your flow. This recipe enables the code command 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 your PATH or 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 code

If which code prints nothing, you need to install the code command (CLI command to run VSCode)

MacOS

  1. 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

  1. Verify:
which code   # expect something like /usr/local/bin/code

3. 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.editor

Validation checklist

  • which code prints a path
  • git config --global core.editor shows code --wait
  • git commit --amend opens VS Code to edit the message
  • git commit --amend --no-edit succeeds 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.