Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Associating Visual Studio Code with Git in Mac

I want to configure my default git editor to Visual Studio Code, but I get the following error after configure it and then use it:

username ~ $ git config --global core.editor "code --wait"
username ~ $ git config --global -e
hint: Waiting for your editor to close the file... code --wait: code: command not found  
error: There was a problem with the editor 'code --wait'.

I have no idea how to fix it... Do you know how I could do it?

Thanks!!

like image 599
Jessica Avatar asked Dec 19 '18 09:12

Jessica


2 Answers

On your VSCode,

SHIFT+Command+P

Shell Command: Install 'code' command in PATH

It will set 'code' to executable PATH of vscode.

Now run below in terminal:

git config --global --edit

like image 107
informagician Avatar answered Nov 10 '22 12:11

informagician


This happens because the code command is not added in PATH. Follow these steps to add the code command in PATH:

  1. Press SHIFT+Command+P.
  2. A input field comes up. Type code install and an option

Shell Command: Install 'code' command in PATH`

comes up. Click on that.

  1. The code command gets added to PATH.
like image 3
Sonu Sourav Avatar answered Nov 10 '22 12:11

Sonu Sourav