Last weekend, I discovered that the VS Code CLI has a --wait
flag, or -w
for short. This flag causes your shell to “Wait for the files to be closed before returning.” This means you can use VS Code as your text editor for git.
To configure VS code as your text editor for git, run the following command. If you’re on macOS, you may need to add the code
command to your PATH
first.
git config --global core.editor "code --wait"
The result is that git will open VS Code whenever it needs your input. When you save and close the file, you will be returned to your shell to complete the git operation. The following GIF shows an example of this.

git commit
command without any arguments, git will open your text editor.The git config core.editor commands section in the official git documentation shows how to set up a number of popular editors. The --wait
flag discussed in this post is listed there.