添加丢失的 LFS 文件导致:遇到 X 文件应该是指针,但不是

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

我有一个 git 存储库,其中包含现有文件。然后我设置 git-lfs 来处理特定类型的文件(例如 pdf、tif 等)。这适用于新文件,它们按预期存储在 LFS 中。然而,已经在 repo 中但应该存储在 LFS 中的文件却没有。这导致在克隆 repo 时出现以下错误:

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

如何转换这些文件以便将它们存储在 LFS 而不是 git 中?我不在乎重写历史,只是需要整理一下才能继续前进。

我是怎么解决的:

  • 创建了一个新分支
  • 复制所有文件
  • 删除了列出的那些应该是指针的。提交此更改
  • 已将文件复制给 re-add 他们
  • 将新文件提交到 git(然后将它们添加到 LFS 而不是 git 存储库)
  • 推送更改

我是怎么解决的:

git lfs migrate import --no-rewrite path

参见:https://tech-notes.maxmasnick.com/fixing-files-that-should-have-been-pointers-in-lfs-but-werent