9

I cannot set Visual Studio Code as my core editor for git. When I'm trying to do the git commit I only see the info that there is a problem with editor.

MacBook-Air-Agata:~ agataskrzypczyk$ git config --global core.editor "/Applications/Visual Studio Code.app" --wait

MacBook-Air-Agata:~ agataskrzypczyk$ git config --global core.editor
/Applications/Visual Studio Code.app

MacBook-Air-Agata:~ agataskrzypczyk$ cd nowy

MacBook-Air-Agata:nowy agataskrzypczyk$ git commit

hint: Waiting for your editor to close the file... /Applications/Visual Studio Code.app: /Applications/Visual: No such file or directory
error: There was a problem with the editor '/Applications/Visual Studio Code.app'.
Please supply the message using either -m or -F option.
MacBook-Air-Agata:nowy agataskrzypczyk$
Diogo Rocha
  • 9,759
  • 4
  • 48
  • 52
Agata Skrzypczyk
  • 91
  • 1
  • 1
  • 2
  • https://stackoverflow.com/search?q=%5Bgit%5D+VScode+core+editor – phd Mar 28 '19 at 00:11
  • An alternative approach to the answers below is to set your EDITOR environment variable as described in [this](https://stackoverflow.com/a/57144660/10682164) answer. Provides more flexibility in case you happen to use multiple editors for different contexts. – totalhack Jul 19 '20 at 12:57

2 Answers2

23

I suggest you to set Visual Studio Code option to be launched from command line. For this follow the instructions in the documentation here.

  • Launch VS Code.
  • Open the Command Palette (⇧⌘P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.

Then try setting core editor with this command:

git config --global core.editor "code --wait"

And then I think you'll not have problems with git commit.

Diogo Rocha
  • 9,759
  • 4
  • 48
  • 52
  • hint: Waiting for your editor to close the file... error: cannot run atom: No such file or directory error: unable to start editor 'atom' Please supply the message using either -m or -F option. – Muhammad Umer Nov 19 '19 at 15:26
  • Worked for me! Ran `git commit --allow-empty` after the above line of code, and got no problem! Thanks! – Steven Choi Nov 20 '19 at 01:17
8
git config --global core.editor "code"
Dharman
  • 30,962
  • 25
  • 85
  • 135
Everton Sales
  • 311
  • 3
  • 3
  • 2
    Please add some explanation, how your solution solves the problem – Anna Oct 27 '19 at 01:02
  • 3
    Literally ran this in my cli as admin and then I typed git commit in phpstorm and it opened vs code...allowing me to type my commit message in vs code. Thank you for this. – CodeConnoisseur Dec 13 '19 at 15:27