从git仓库中删除丢失的LFS对象 [英] Removing missing LFS objects from git repository

查看:573
本文介绍了从git仓库中删除丢失的LFS对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在客户端和服务器上的git仓库*中都缺少一堆LFS对象.我知道这些对象丢失了,没关系.不幸的是,这意味着git lfs fetch --all甚至git lfs push --all origin都会失败.

I am missing a bunch of LFS objects in my git repository*, both on the clients and the server. I am aware that those objects are lost and that's okay. Unfortunately this means that git lfs fetch --all or even git lfs push --all origin will fail.

我想从存储库中清除损坏的指针",方法是将二进制文件替换为虚拟文本文件,或者完全删除指针.我还知道这涉及重写历史记录,这也很好.

I would like to purge the "broken pointers" from the repository, either by replacing the binary with a dummy text file or by removing the pointer altogether. I am also aware that this involves rewriting history and that's also fine.

什么是最好的进行方式?

What would be the best way to proceed?

*为了澄清,我丢失了服务器上的一些 LFS文件,但不是全部,也不是这些文件的所有修订版.

*To clarify, I am missing some LFS files on the server but not all of them and not for all revisions of those files.

例如,我有经过3次提交修改的foo.png:

For example, I have foo.png that has been modified in 3 commits:

  • foo.png(版本1,LFS Sha:03cfd743)
  • foo.png(版本2,LFS Sha:661f0797)
  • foo.png(Version 3,LFS Sha:5fa2f122)

LFS服务器不再具有foo.png版本2,因此我想从历史记录中删除该提交.不幸的是,git lfs不会告诉我哪个提交被破坏了,它只是告诉我661f0797丢失了.

The LFS server no longer has foo.png version 2, so I would like to remove that commit from history. Unfortunately git lfs does not tell me which commit is broken, it simply tells me that 661f0797 is missing.

(为便于记录,我已经找到了丢失的文件,所以我不再遇到这个问题,但是解决方案应该仍然很有趣!)

(For the record, I have found the missing files so I no longer have this issue but the solution should still be interesting!)

推荐答案

您可以untrack文件,即只需一个文件:

git lfs untrack "/path/to/my-file.gif"

使用通配符,您可以通过一个命令捕获多个文件:

With wildcard you can catch several files by one command:

git lfs untrack "*.gif"

这篇关于从git仓库中删除丢失的LFS对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆