I have a Git repo with LFS installed and working properly. On my dev
branch, I renamed an image file (tracked by LFS) from NoMedal-Fade.png
to None-Fade.png
with the Windows file Explorer. I committed, pushed onto GitLab, and it went great.
Then, in another instance of this repo on my computer (this repo is on another branch called production/foo
, I ran git fetch
, and git merge origin/dev
to get and merge the modifications I just made in the other instance. This is where I have troubles understanding what's happening: the merging failed with this error:
error: add_cacheinfo failed to refresh for path '■■■■/■■■■/■■■■/■■■■/■■■■/■■■■/None-Fade.png'; merge aborting.
And this added the new file in the unstaged modifications:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: ■■■■/■■■■/■■■■/■■■■/■■■■/■■■■/None-Fade.png
In my incomprehension, I tried to git reset --hard
, but the file was still here. I tried to git checkout <file path>
, but the file was still here. I deleted the instance, cloned back, and tried again the same process, still same problem. I tried to stage the file I wanted to have, committed it and pushed it. Now the file doesn't show up anymore in the unstaged files list, but i still can't merge because of this same error aforementioned (add_cacheinfo
). Finally, a friend of mine told me to try git config core.fscache false
before merging, unfortunately, nothing changed (same for global config).
PS C:\Users\■■■■> git --version
git version 2.24.0.windows.2
Okay so the only thing I found was to reset the branches before the file was renamed, with git reset --hard <commit hash before rename>
and git push origin <remote branch>:<local branch> --force
to update the remote.
WARNING: keep in mind that this latter command is very dangerous if you work with several people. Given that I'm the only one with a friend on this project, it was easy to tell him to clone the project back and avoid bigger errors.
After having erased from the history the faulty commits, I renamed the file once again with git mv <file name> <new file name>
instead of using Windows' file explorer. It worked well, apparently, I have no more issue with the file.
But still, this is not a real solution to the issue, more like a workaround. I'll keep my answer as the best solution until someone finds something else.