LoginSignup
1
0

More than 1 year has passed since last update.

GitのエディターをVS Codeに変えようとしたらはまった件

Posted at

GitのエディターをVS Codeに変えようとしたらはまりました。

何が起きたか?

色々なサイトを見ていると、GitのエディターをVS Codeに変更するには、

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

と書くといいようなのですが、自分はこの設定でコミットしようとすると、

hint: Waiting for your editor to close the file... /c/Users/xxx/AppData/Local/Programs/Microsoft VS Code/bin/code: line 14: realpath: command not found
/c/Users/xxx/AppData/Local/Programs/Microsoft VS Code/bin/code: line 61: ./Code.exe: No such file or directory
error: There was a problem with the editor 'code --wait'.
Please supply the message using either -m or -F option.

というエラーになってしまいました。

対策

色々試行錯誤した結果、

git config --global core.editor 'code.cmd --wait'

とすれば無事VS Codeでコミットメッセージが書けるようになりました。エラーの原因はよくわかりませんでした・・・。codeにもcode.cmdにもパスは通っているはずです。

備考

ちなみに自分はVisual Studioと一緒にGitをインストールした(はずな)ためこうなりましたが、Git for Windowsを個別にインストールする際にVS Codeをエディターとして設定すれば、おそらくこの問題は起こらなかったと思います。

参考サイト

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0