How to solve 'error: add_cacheinfo failed to refresh for path' when merging at a project containing a submodule
Asked Answered
N

2

8

I have a project with a submodule. When trying to merge a branch (named release) into master, git identified some conflicts and raised the following error:

Fast-forwarding submodule path/to/submodule
Auto-merging path/to/submodule
error: add_cacheinfo failed to refresh for path 'path/to/submodule'; merge aborting.

It completely stopped the merge, as no evidence of it is shown with git status, although I can see some files from the branch release. If I run git merge --abort it also complains with:

fatal: There is no merge to abort (MERGE_HEAD missing).
Nonconformance answered 23/7, 2020 at 14:55 Comment(1)
A fast-forward operation isn't a merge after all, so even if it hadn't aborted on its own, there would still be no merge to abort for this case. Still, Git should have detected this earlier and not left you with a melange.Cobblestone
N
7

First I had to reset my branch master with:

git reset --hard origin/master

and delete any files that stayed from the aborted merge (files that came from the release).

After, I updated the submodule to the latest version in both branches, with:

git submodule update --recursive --remote

After that I was able to run the merge without further problems with add_cacheinfo.

Nonconformance answered 23/7, 2020 at 14:55 Comment(2)
I encourage you to report this bug to the Git mailing list: [email protected], with steps to reproduce if possible.Fractional
I use git rebase my develop branch from master. The same error happens. I get solved with forcing my develop branch submodule to be the same commit id with master branch.Fescue
D
0

I experienced this issue with Git 2.30.2, and it was solved with Git 2.39.2.


My exact situation was: multiple submodules fast-forwardable and a few in-conflict, and I cherry-picked another commit overriding these submodules and other files. Here is a workaround with Git 2.30:

  • one of the fast-forwardable submodules triggers the error message error: add_cacheinfo failed to refresh for path 'path/to/submodule'; merge aborting.;
  • the cherry-pick is aborted but some files from the cherry-pick operation are modified, so these files must be restored to their unmodified version to be able to reapply the cherry-pick (git checkout -- file1 file2);
  • it can be workaround with git submodule update path/to/submodule but then the next fast-forwardable submodule triggers the same error, so you have to execute git submodule update for all fast-forwardable submodules (in-conflict submodules do not need to be updated);
  • reapply the cherry-pick, it should work and warn about in-conflict submodules (if there are some).
Degust answered 13/10, 2023 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.