You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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
      
  • 验证:重新执行 git config --edit --global,配置文件将以你指定的编辑器正常打开。

内容的提问来源于stack exchange,提问作者iamdeed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 11:03:16