运行git commit时与编辑器有关的错误?

时间:2015-02-03 08:29:08

标签: git

运行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.

这是什么意思?我该如何解决?

2 个答案:

答案 0 :(得分:3)

我刚刚遇到这个问题,发现你的问题试图解决这个问题。我也认为它需要转义空格和括号IN .gitconfig的转义字符,但显然不是。这句话对我有用:

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

通过以下命令在我的.gitconfig文件中创建了它:

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

我必须删除无效行,然后使用上面的命令设置它将起作用。

不幸的是,git commit仍然没有用。在它周围添加引号和单引号最终工作,在我运行的Notepad ++窗口中启动COMMIT_EDITMSG:

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

平台是Windows 8.1 Pro x64,MINGW64 / Bash shell,从https://git-scm.com Windows客户端安装。

答案 1 :(得分:1)

看起来gitconfig中的prepare-commit-msg挂钩或editor选项有拼写错误。你打电话给c:/Program/ Files/ /(x86/)/Notepad++/notepad++.exe,但你应该调用c:/Program\ Files\ \(x86\)/Notepad++/notepad++.exe(使用反斜杠来逃避空格和括号,而不是斜线)