原始报错与特征码
2026-11-08fatal: could not read Username for 'https://github.com': terminal prompts disabled. Submodule 'vendor/core' could not be initialized.根本原因分析
在自动化智能体无人值守执行时,默认禁用了交互式 TTY 终端。如果被拉取的工程包含私有 Submodule 或未免密的 Git 仓库,Git 尝试在后台弹出凭据输入,直接触发非零退出中断。
可复制解法与生产配置
- 在执行前注入环境凭证:
git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"; - 或改用 SSH 密钥挂载,并预先配置
~/.ssh/config和StrictHostKeyChecking no; - 克隆主项目时明确携带参数:
git clone --recurse-submodules。