# 子模块更新报错
$ git submodule update
Submodule path 'project1': checked out 'f0246e6589fcb0f80e62f99c5ac39cfb397aff9d'
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
error: Server does not allow request for unadvertised object760fdec22c33e28eac20de661e4e6ce0e24c8549
Fetched in submodule path 'project2', but it did not contain 760fdec22c33e28eac20de661e4e6ce0e24c8549. Direct fetching of that commit failed.
通过字面上面的意思,说是主项目中记录的 submodule 的 HEAD 超前,导致找不到指定的 commit 信息。可能你也很奇怪,自己什么都没有做,而且使用的 CI 自动进行环境更新的,理论上来说,不应该出错才对。在网上查阅了一下资料,觉得下面的解释还比较可信:
现有 main 主仓库,里面有子模块对应的 sub 仓库。用户修改了 sub 中的文件,但没有提交到 sub 的远程库,然后把 main 提交到了远程库。现在,另外一个人尝试把 main 拉去下来并同步 sub 中的修改时,由于 sub 的改动并未 push 到其对应的远程库,但 update 命令尝试从 sub 的远程库 pull 对应的改动,因此也就不存在,就会报错。
因此,如果在 main 仓库中修改 sub 子模块,记得一定要先 push sub 中的修改,再 push main 中的修改,否则别人 update 的时候会报错。