3

尝试将存储库(包括历史记录)迁移出 Git LFS。

我在测试存储库上运行(在此处git lfs migrate export --include="*" --everything提到),但它没有按预期工作,并留下 LFS 指针文件,而不是将它们全部转换为对象。

我尝试了替代方法,遵循this。不幸的是它仍然留下指针文件,所以我将它与this结合起来。

最后,我什至将所有命令一起运行:

git lfs uninstall
git filter-branch -f --prune-empty --tree-filter '
  git lfs fetch
  git lfs checkout
  git lfs ls-files | cut -d " " -f 3 | xargs touch
  git lfs ls-files | cut -d " " -f 3 | xargs git rm --cached
  git rm -f .gitattributes
  git lfs ls-files | cut -d " " -f 3 | xargs git add --force
  git add --renormalize .
' --tag-name-filter cat -- --all

没用。给我多个文件的以下错误,过滤的提交有指针文件而不是对象。

Errors logged to <PATH>
Use `git lfs logs last` to view the log.
Rewrite <COMMIT SHA ####> (2/9) (2 seconds passed, remaining 7 predicted)    
Checking out LFS objects:   0% (0/1), 0 B | 0 B/s           
Checking out LFS objects: 100% (2/2), 3.1 KB | 0 B/s, done
Error updating the git index:
error: picture.png: cannot add to the index - missing --add option?
fatal: Unable to process path picture.png

我尝试仅在提示提交上运行相同的命令,似乎touch, rm --cached, add --renormalize .,add --force不显示任何修改git status。所以我无法将清理/拉取的目标文件重新添加到新的提交中。

也许这就是问题所在?那么如何在使用filter-branch时强制将未更改的文件重新添加到索引中呢?

(使用带有 git bash 的 Windows。)

4

1 回答 1

3
  1. git lfs migrate export --everything --include .git 历史记录中的真实文件替换所有 LFS 指针。有关更多详细信息,请参阅http://stackoverflow.com/a/57681990/717372

  2. 运行git lfs uninstall以删除 lfs 挂钩。

  3. 并验证是否.gitattributes已删除 lfs 过滤器。

    如果未删除 lfs 过滤器,并且.gitattributes仅 LFS 需要,请使用以下命令删除所有历史记录中的文件:

    git filter-branch -f --prune-empty --tree-filter '
      git rm -f .gitattributes --ignore-unmatch
    ' --tag-name-filter cat -- --all
    

    否则,如果.gitattributes有非 LFS 行,则通过将上述树过滤器命令替换为git lfs untrack(参考此处此处)仅删除 LFS 过滤器。

于 2020-01-03T09:12:43.830 回答