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

使用新版Git推送至GitHub时遇fatal: bad boolean config value报错如何解决?

解决Git推送报错:fatal: bad boolean config value 'origin' for 'push.autosetupremote'

问题原因

push.autosetupremote是Git的布尔/枚举型配置项,有效值为true、false、always、never、simple,你的配置被错误设置为字符串origin,导致Git无法解析,触发报错。

解决步骤

  1. 确认当前错误配置值
    执行命令查看配置:

    git config --get push.autosetupremote
    

    会输出origin,验证问题所在。

  2. 修改为合法配置值
    根据需求选择以下命令之一:

    • 全局生效(所有Git项目):
      # 开启自动设置远程分支关联(推荐)
      git config --global push.autosetupremote true
      # 或者关闭该功能
      git config --global push.autosetupremote false
      
    • 仅当前项目生效:
      去掉命令中的--global参数即可:
      git config push.autosetupremote true
      
  3. 完成推送操作
    如果还未关联GitHub仓库,先执行:

    git remote add origin <你的GitHub仓库地址>
    git branch -M main  # 将本地分支重命名为main(GitHub默认分支名)
    

    推送部分文件的话,先提交修改:

    git add <要推送的文件或目录路径>
    git commit -m "提交说明"
    

    最后执行推送:

    git push -u origin main
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 12:48:14