Git Bash执行git config --edit --global时出现语法错误的问题求助
解决Git默认编辑器为Visual Studio 2017引发的语法错误
执行命令 git config --edit --global 时出现如下错误:
hint: Waiting for your editor to close the file... C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe: -c: line 1: syntax error near unexpected token `('
问题根源是Git默认将Visual Studio 2017的devenv.exe设为核心编辑器,其路径包含空格和括号,导致Git Bash解析时触发语法错误。
解决步骤:
- 查看当前编辑器配置:
git config --global core.editor - 修改为目标编辑器(以下为常见选项,选其一执行即可):
- 使用Notepad++:
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" - 使用Git自带的nano编辑器:
git config --global core.editor nano - 使用Windows记事本:
git config --global core.editor notepad
- 使用Notepad++:
- 验证:重新执行
git config --edit --global,配置文件将以你指定的编辑器正常打开。
内容的提问来源于stack exchange,提问作者iamdeed
相关产品推荐
相关产品推荐

