在包含子模块的项目中合并时如何解决“错误:add_cacheinfo 无法刷新路径”

rjm*_*aro 4 git git-submodules

我有一个带有子模块的项目。尝试将分支(名为release)合并到 中时master,git 识别出一些冲突并引发以下错误:

Fast-forwarding submodule path/to/submodule
Auto-merging path/to/submodule
error: add_cacheinfo failed to refresh for path 'path/to/submodule'; merge aborting.
Run Code Online (Sandbox Code Playgroud)

它完全停止了合并,因为没有显示它的证据git status,尽管我可以看到分支中的一些文件release。如果我运行git merge --abort它也会抱怨:

fatal: There is no merge to abort (MERGE_HEAD missing).
Run Code Online (Sandbox Code Playgroud)

rjm*_*aro 6

首先,我必须使用以下命令重置我的分支master

git reset --hard origin/master

并删除中止合并中保留的所有文件(来自 的文件release)。

之后,我将两个分支中的子模块更新为最新版本,其中:

git submodule update --recursive --remote

之后,我能够运行合并而没有进一步的问题add_cacheinfo