Error related to editor when running git commit?

孤人 提交于 2019-12-19 20:44:09

问题


I get the following error when running Git commit:

c:/Program/ Files/ /(x86/)/Notepad++/notepad++.exe: -c: line 0: syntax
 error near unexpected token `('
c:/Program/ Files/ /(x86/)/Notepad++/notepad++.exe: -c: line 0: `c:/Pr
ogram/ Files/ /(x86/)/Notepad++/notepad++.exe \$@\'
error: There was a problem with the editor 'c:/Program/ Files/ /(x86/)
/Notepad++/notepad++.exe'.
Please supply the message using either -m or -F option.

What does it mean? How can I fix it?


回答1:


I was just running into this, and found your question trying to figure it out. I too assumed it needed escape characters for the spaces and parentheses IN .gitconfig, but apparently not. This statement worked for me:

editor = C:/Program Files (x86)/Notepad++/notepad++.exe

Which was created in my .gitconfig file by the below command:

git config --global core.editor /c/Program\ Files\ \(x86\)/Notepad\+\+/notepad\+\+.exe

I had to remove the invalid line, before setting it with the above command would work.

Unfortunately, git commit still didn't work. Adding both Quotation marks and single quotes around it finally worked, launching the COMMIT_EDITMSG in my running Notepad++ window:

editor = "'C:/Program Files (x86)/Notepad++/notepad++.exe'"

Platform is Windows 8.1 Pro x64, the MINGW64/Bash shell, installed from the https://git-scm.com Windows client.




回答2:


Looks like the prepare-commit-msg hook or the editor option in the gitconfig has a typo. You call c:/Program/ Files/ /(x86/)/Notepad++/notepad++.exe but you should have called c:/Program\ Files\ \(x86\)/Notepad++/notepad++.exe (use backslashes to escape space and bracket, not slash)



来源:https://stackoverflow.com/questions/28294375/error-related-to-editor-when-running-git-commit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!