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

使用GitHub Actions部署时拉取Git子模块失败,报错退出码128

GitHub Actions拉取子模块失败(退出码128)解决方案

问题场景

使用GitHub Actions自动化部署到App Service时,拉取私有子模块仓库失败,返回Git退出码128,错误日志如下:

/usr/bin/git config --local --name-only --get-regexp core\.sshCommand

73  /usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"

74  /usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader

75  http.https://github.com/.extraheader

76  /usr/bin/git config --local --unset-all http.https://github.com/.extraheader

77  /usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"

78Error: The process '/usr/bin/git' failed with exit code 128

解决步骤

1. 确认子模块URL协议

确保父仓库中子模块的URL使用HTTPS协议,而非SSH。如果是SSH地址,改成https://github.com/<用户名>/<子模块仓库名>.git,这样才能配合PAT完成认证。

2. 检查PAT权限

  • 确保创建的PAT拥有repo权限(勾选所有repo相关权限),且该PAT能访问子模块所在的私有仓库。
  • 不要使用默认的GITHUB_TOKEN,因为它仅对当前仓库有访问权限,无法跨仓库访问私有子模块。

3. 正确配置Checkout步骤

在GitHub Actions workflow中,修改actions/checkout步骤,明确开启递归拉取子模块,并指定你的PAT:

- name: 拉取代码及子模块
  uses: actions/checkout@v4
  with:
    submodules: recursive  # 递归拉取所有子模块
    token: ${{ secrets.YOUR_PAT_SECRET_NAME }}  # 替换为你在仓库Secrets中存储的PAT名称

4. 清理Git配置残留

从错误日志看,存在Git配置冲突的可能,可在checkout后添加步骤清理相关配置:

- name: 重置子模块Git配置
  run: |
    git config --local --unset-all http.https://github.com/.extraheader
    git submodule foreach --recursive git config --local --unset-all http.https://github.com/.extraheader

5. 本地验证PAT有效性

在本地终端用PAT克隆子模块仓库,确认认证正常:

git clone https://<你的PAT>@github.com/<用户名>/<子模块仓库名>.git

如果克隆失败,说明PAT权限或配置有问题,需重新生成或调整权限。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 08:32:03