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

Windows10下Git Bash报错“无法打开/dev/null”的解决求助

解决Windows 10下Git Bash无法打开/dev/null的错误

问题说明

安装Git Bash时出现以下核心错误,安装完成后执行git --version仍触发相同报错:

Unable to set system config "diff.astextplain.textconv":="astextplain": exit code 128,stderr: fatal: could not open '/dev/null' for reading and writing: No such file or directory
已尝试修改注册表HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Null的Start值为1(原值已是1),无效。

分步解决方案

  • 修复Null设备驱动

    1. 按Win+R输入devmgmt.msc打开设备管理器
    2. 展开「非即插即用驱动程序」,找到「Null」设备
      • 若有黄色感叹号:右键卸载设备,再点击「操作」>「扫描检测硬件改动」,系统会自动重装驱动
      • 若无感叹号:右键禁用设备,10秒后重新启用
  • 重置Git系统配置

    1. 强行打开Git Bash,执行命令重置配置:
      git config --system --unset diff.astextplain.textconv
      git config --system diff.astextplain.textconv astextplain
      
    2. 若命令报错,手动修改Git系统配置文件:
      找到C:\Program Files\Git\etc\gitconfig,用记事本打开,确保[diff "astextplain"]段为:
      [diff "astextplain"]
          textconv = astextplain
      
      删除任何格式错误的同项配置
  • 重新注册Null系统服务

    1. 以管理员身份打开命令提示符,执行:
      sc config null start= auto
      sc start null
      
    2. 验证设备是否正常:
      type NUL > test.txt && del test.txt
      
      无报错则说明Null设备恢复正常
  • 干净重装Git

    1. 卸载Git:进入「设置」>「应用和功能」找到Git并卸载
    2. 删除残留目录:C:\Program Files\Git、C:\Users\<你的用户名>\.gitconfig、C:\Users\<你的用户名>\AppData\Local\Git
    3. 下载最新稳定版Git for Windows,安装时选择「Use Git Bash only」,避免PATH环境冲突

内容的提问来源于stack exchange,提问作者Md. Jahangir Alam

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 23:25:19