Search code examples
gitgit-lfs

Adding missing LFS files that causes: Encountered X file(s) that should have been pointers, but weren't


I've got a git repository that had existing files in it. I then setup git-lfs to handle files of particular types (e.g. pdf, tif etc). This works fine for new files and they are stored in LFS as expected. However, files that were already in the repo but should have been stored in LFS aren't. This leads to the error below when cloning the repo:

Encountered 361 file(s) that should have been pointers, but weren't:

How can I convert these files over so that they are stored in LFS rather than in git? I don't care about rewriting history, just need to tidy this up for moving forward.


Solution

  • How I solved it:

    • Created a new branch
    • Took a copy of all the files
    • Deleted the ones listed that should have been pointers. Committed this change
    • Copied over the files to re-add them
    • Committed the new files to git (this then added them into LFS rather than the git repository)
    • Pushed the changes