Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix git commit error "Waiting for your editor to close the file..." with VS Code?

I'm trying just git commit and Git is giving this message:

hint: Waiting for your editor to close the file... /c/Users/AGT/AppData/Local/Programs/Microsoft VS Code/bin/code: line 28: /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.

I'm using, or trying it, VS Code as default and I got this same message with it opened or closed. Commits done through VS Code or by command git commit -m "Initial commit" works fine.
I tried change config path with:

  • git config --global core.editor "code --wait"
  • git config --global core.editor "'C:\Users\AGT\AppData\Local\Programs\Microsoft VS Code\Code.exe' -n -w" and the followed variants(these with this change at error message "unexpected EOF while looking for matching"):
  • C:\Users\AGT\AppData\Local\Programs\Microsoft VS Code\bin
  • C:\Users\AGT\AppData\Local\Programs\Microsoft VS Code\bin\code
  • C:\Users\AGT\AppData\Local\Programs\Microsoft VS Code\Code.exe

No success at all.

The git status is:

    On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   css/app.css
        new file:   index.html
        new file:   js/app.js

How can I fix that to git commit command through Git BASH works fine with Vs Code? It's seems path issue.

Update info: I tested git commit with Sublime 3 and it works fine.

like image 700
AGT Avatar asked Sep 06 '18 02:09

AGT


People also ask

How do I close a git commit?

Typing :wq and pressing enter should do it, i.e. save the commit message and exit.

How do I change the default git editor?

The command to do this is git config --global core. editor "nano" . You can change the highlighted section with your editor of choice!

How do I commit in git?

To add a Git commit message to your commit, you will use the git commit command followed by the -m flag and then your message in quotes. Adding a Git commit message should look something like this: git commit -m “Add an anchor for the trial end sectionnn.”


3 Answers

Have you confirmed that code is accessible from the command line where you execute git commands?

You could run code --version

BTW. When I execute where code I get C:\Program Files\Microsoft VS Code\bin\code - it's no longer installed in the %App_Data% folder. However, this should be irrelevant if you only specify code --wait without the path.

In other words, here is the procedure I would attempt:

  1. Confirm code --version works in the console you use for git
  2. git config --global core.editor "code --wait"
  3. Change things in you branch and then git commit. Does VS Code start and show COMMIT_EDITMSG file? enter image description here
like image 165
tymtam Avatar answered Oct 20 '22 03:10

tymtam


Putting the name of the editor in double quotes produced this error for me. Put the name of the editor in single quotes, like:

git config --global core.editor 'vi'

Or, try switching to double quotes if you're already using single quotes.

like image 33
schulwitz Avatar answered Oct 20 '22 04:10

schulwitz


git config --global core.editor /usr/bin/vim solved it for me.

like image 34
Anupam Maurya Avatar answered Oct 20 '22 04:10

Anupam Maurya