修复 git-lfs 用户错误

问题描述 投票:0回答:2

我们在 gitlab 中有一个启用了 git-lfs 的存储库,它工作得很好。它很好地分离了 pdf、电影和其他我们不想进行版本管理的内容。

出现用户错误,有人在未启用 git-lfs 支持的系统上克隆存储库。那个人将一个 pdf 文件添加到 git 并推送回服务器。

然后另一个用户在有 git-lfs 的系统上获取该分支,并尝试检查它:

   $ git checkout pj-guide_47_mac_R_setup
   Switched to branch 'pj-guide_47_mac_R_setup'
   Your branch is behind 'origin/pj-guide_47_mac_R_setup' by 14 commits, and can be fast-forwarded.
    (use "git pull" to update your local branch)
    Encountered 1 file(s) that should have been pointers, but weren't:
        47.mac_R_setup/47.mac_R_setup-slides.pdf 

正确配置 git-lfs 来修复该 pdf 文件的系统上最直接的路线是什么?根据 https://github.com/git-lfs/git-lfs/issues/1726 有 git lfs merge import 与 git-lfs 2.3.0 一起发布的用法,但我无法理解如何使用它。

git-lfs
2个回答
5
投票

我在 git-lfs 问题跟踪器中针对略有不同的用例提出了类似的问题。 git-lfs 问题 2845

@larsxschneider 给出了这个答案:

“最简单的方法是这样的:

git rm --cached <PROBLEM FILE>
git add --force <PROBLEM FILE>
git commit -m "Move files properly to GitLFS"

这会将 PDF 文件的内容从纯 Git 复制到 Git LFS。此方法的缺点是内容的当前版本保留在纯 Git 历史记录中(这可能会增加存储库的大小)。不过,未来的每次内容更新都将仅在 Git LFS 中进行。”

该作者建议我避免“git lfs migrate import”,除非紧急情况。如果涉及多个用户,历史记录的更改可能会造成严重破坏。”

Lars Schnieder 还提到了有关此的新 Youtube 演示。 “GitLFS - 如何在 Git 中处理大文件 - Lars Schneider - FOSSASIA 峰会 2017”


0
投票

对我来说,最简单的解决方案是:

git lfs migrate import --no-rewrite path/to/file.ext

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

© www.soinside.com 2019 - 2024. All rights reserved.