1
0

More than 1 year has passed since last update.

【Git】VSCode上でgit commitを実行するとエラー発生。解決方法

Posted at

はじめに

Gitの操作方法を学ぶため、Udemyの教材を見ながらGitを動かしていたところ、git commitを実行した際にエラー発生!
git addまではうまく動作したのに何故!ということで原因を調べて、解決したのでその方法について書きます。
前提として、以下のことはできていました。
①git addまでは問題なく実行できていた
②git config --global core.editor "code --wait"でVSCodeをデフォルト設定していた

エラー内容

zsh
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'.
Please supply the message using either -m or -F option.

「ファイルを閉じるのを待っている??」と考え、VSCodeで開いていたファイルを閉じて再度git commitするも同じエラー。

次に'code --wait'という文面を見て、「さっきVSCodeをデフォルトに設定したけど、方法を間違ってたか?」と考え、cat ~/.gitconfigで確認すると「editor = code --wait」と表示され間違ってはなさそう。

解決方法

原因が全くわからなかったので、「vscode git commit hint: Waiting for your editor to close the file...」で調べてみるとQiita記事で同じようなエラー発生している人を発見。

結果的には、コマンドラインでVSCodeを開くためのCodeコマンドがインストールされていなかったのが原因でした。

解決方法としては、VSCode内で「Command + Shift + p」を押し、コマンドパレットを開き、
Shell Command: Install 'Code' command in pathと入力し、Codeコマンドをインストール。
その後、無事git commitすることができました。

参考記事

以下の記事を参考にさせていただきました。

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