How can I fix git commit error "Waiting for your editor to close the file..." with VS Code?
GitVisual Studio-CodeGit CommitGit Problem Overview
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.
Git Solutions
Solution 1 - Git
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:
Solution 2 - Git
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.
Solution 3 - Git
git config --global core.editor /usr/bin/vim
solved it for me.
Solution 4 - Git
For people having Atom as default editor for Git-related stuff
When Atom was a default code editor for it, there was some kind of conflict between Atom and Visual Studio Code. Opening a Terminal in Visual Studio Code and hitting git config --global core.editor "code --wait"
solved the problem. Then Visual Studio Code opened a new tab each time I was doing something in the console without crashing.
Solution 5 - Git
If your in vs code go to your source control tab on the left
then type in your comment, press ctrl & enter
if you do git status it should say nothing to commit, working tree clean..that means it worked
Solution 6 - Git
Any file may be opened in any editor. So run "ps -ax|grep vim" to check which file is opened in which editor. And then run kill id-of-editor . For e.g. "kill 12345" Thats all
Solution 7 - Git
Maybe this might help someone
For me, i forgot to add vscode to path after re-installing.
To add a file or folder to a path, follow these steps:
search for varibles => Enviornment variables => path => edit => paste the full path to file or folder or hit browse and select the path => click ok and exit.
Solution 8 - Git
It is expecting you to enter the comments regarding the commit you are making enter comment and it should commit the code.
Solution 9 - Git
I got that error while i configured with Atom.
I got it solved by opening the app in background before executing the command git commit
You can also try using $ git commit -m "Initial commit"
It directly passes the message without waiting for the editor to open
NOTE: You wont be able to add description just a comment
Solution 10 - Git
It looks like it has to do with the path of VS Code in your case and possibly the command to set the editor git config --global core.editor "code --wait"
not being correct.
In my case, I couldn't complete a merging command.
What really worked for me after ensuring that VS Code is correctly setup :
code --version
worked fine. Executing where code showed me that the installation of code was in a different location than the local app data, which was where git was looking in. I could also tell code could not really be found because the editor was not launching when I was merging.
Finally executing
git config --global core.editor 'code --wait'
did the trick for me. Not that it's in single quotes as suggested further up in one of the comments.
Solution 11 - Git
Change git commit
to git commit -m "Title of your update"
.