git推送远程仓库报错:Bad configuration option: \357\273\277include
git推送远程仓库报错:Bad configuration option: \357\273\277include
- 完整解决方案
git推送远程仓库报错
c/Users/xxx/.ssh/config: line 1: Bad configuration option: \357\273\277include
/c/Users/xxx/.ssh/config: terminating, 1 bad configuration options
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
这个错误是由 SSH 配置文件 (~/.ssh/config
) 的编码问题 引起的。具体表现为:
1. \357\273\277
是 UTF-8 BOM(字节顺序标记) 的八进制表示
2. SSH 客户端无法识别开头的 BOM 字符,导致将 include
指令解析为无效配置
3. 最终导致 Git 无法通过 SSH 访问远程仓库
完整解决方案
移除 BOM 标记
- 使用以下命令清理配置文件的 BOM:
# 使用 sed 移除 BOM (Linux/macOS/WSL) sed -i '1s/^\xEF\xBB\xBF//' ~/.ssh/config # PowerShell (Windows) (Get-Content -Path ~/.ssh/config -Raw) -replace '\xEF\xBB\xBF', '' | Set-Content -Path ~/.ssh/config -NoNewline
- 本地用Notepad++打开config文件,检查文件格式是否是 UTF-8 BOM,并将其手动调整为UTF-8,保存之后重试推送。