简体   繁体   English

GitLab 和 LFS 推送丢失的文件

[英]GitLab and LFS Pushing with Missing Files

I have a very old repository I have been using and at some point some LFS files have gone missing.我有一个非常旧的存储库,我一直在使用,并且在某些时候丢失了一些 LFS 文件。 Quite a few of them.其中不少。 When I try and push to a new repository in Gitlab, I get the following error当我尝试推送到 Gitlab 中的新存储库时,出现以下错误

 GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual 

Other QA for git-lfs ( here , here ) indicate that usually some variant of git lfs push --all but I don't have a working repo with these files anymore and they are gone for good. git-lfs 的其他 QA(此处此处)表明通常git lfs push --all某些变体,但我不再有这些文件的工作存储库,它们已经一去不复返了。 Gitlab ignores pushing with --no-verify and still gives the error. Gitlab 忽略使用 --no-verify 推送并仍然给出错误。

Running git lfs fetch --all gives a lengthy list of missing OID运行git lfs fetch --all给出了丢失 OID 的冗长列表

[43cb9e6d1d15bb8d31af911aa69a15a67174c5df73dabc85294ce08198cac468] Object does not exist on the server or you don't have permissions to access it: [404] Object does not exist on the server or you don't have permissions to access it
[454907d530534af9cc95903820c0a632a851b45de98ba18e1de117b8a649f8ac] Object does not exist on the server or you don't have permissions to access it: [404] Object does not exist on the server or you don't have permissions to access it
[ce1314f0c4cb05f349540fa144d33faeb2281ae552cf75dc866a8350d90fd2ac] Object does not exist on the server or you don't have permissions to access it: [404] Object does not exist on the server or you don't have permissions to access it
[d5e8925d273cb00341f00d0f40b39f97cced1e833ef687de2d4663836e7f4e45] Object does not exist on the server or you don't have permissions to access it: [404] Object does not exist on the server or you don't have permissions to access it
...

Another post here contains scripts to remove LFS entirely by checking out every commit and smudging LFS files, but this seems highly detrimental to the repository moving forward. 这里的另一篇文章包含通过检查每个提交和涂抹 LFS 文件来完全删除 LFS 的脚本,但这似乎对存储库的前进非常不利。 Still another indicates a path to remove the LFS file entirely ( here ).还有一个表示完全删除 LFS 文件的路径( 此处)。

All these issues seem to be suboptimal:所有这些问题似乎都不理想:

  1. Removing LFS will grossly bloat the repo and the smudge is likely to fail for the files already broken, anyway删除 LFS 会使 repo 严重膨胀,无论如何,对于已经损坏的文件,涂抹可能会失败
  2. Git pull/push -all is not an option because the files are gone for good Git pull/push -all 不是一个选项,因为文件已经一去不复返了
  3. Removing the LFS is not right because a version of the files exist today only the object in some branch in the past is missing, so all instructions on how to remove LFS will break the repo.删除 LFS 是不对的,因为今天存在的文件版本只有过去某个分支中的对象丢失了,所以所有关于如何删除 LFS 的说明都会破坏 repo。

Is there a way to have GitLab not ignore no-verify or to efficiently filter out specific OID from the history?有没有办法让 GitLab 不忽略不验证或有效地从历史记录中过滤掉特定的 OID? I don't mind if the files are missing forever but I had hoped to preserve history.我不介意文件是否永远丢失,但我希望保留历史。

I know that I can run git log --all -p -S 43cb9e6d1d15bb8d31af911aa69a15a67174c5df73dabc85294ce08198cac468 to get the commit and file (though it takes 5-10min to run PER OID, so this would take many hours), but I don't know what to do with that.我知道我可以运行git log --all -p -S 43cb9e6d1d15bb8d31af911aa69a15a67174c5df73dabc85294ce08198cac468来获取提交和文件(虽然它需要git log --all -p -S 43cb9e6d1d15bb8d31af911aa69a15a67174c5df73dabc85294ce08198cac468来运行,但我不知道这需要多少小时)这样做。

I just solved the same issue by the following steps:我刚刚通过以下步骤解决了同样的问题:

The BFG log reported me the following warning: BFG 日志向我报告了以下警告:

Protected commits
-----------------

These are your protected commits, and so their contents will NOT be altered:

 * commit 9edf1837 (protected by 'HEAD') - contains 1 dirty file : 
    - requirements/LMD-SE-10-D11/setupse10d11.exe (132 B )

WARNING: The dirty content above may be removed from other commits, but as
the *protected* commits still use it, it will STILL exist in your repository.

Details of protected dirty content have been recorded here :

<REPO_PATH>/..bfg-report/2021-07-30/14-12-39/protected-dirt/

If you *really* want this content gone, make a manual commit that removes it, 
and then run the BFG on a fresh copy of your repo.

In order to deal with this warning, which prevented me from removing the dirty file at all, I cloned again the repo, but without mirroring it .为了处理这个阻止我删除脏文件的警告,我再次克隆了 repo,但没有镜像它

Now, as suggested by the log, I deleted the dirty file by a commit, and run again the BFG command with the same arguments.现在,正如日志所建议的那样,我通过提交删除了脏文件,并使用相同的参数再次运行 BFG 命令。

Finally, I issued the commands:最后,我发出了以下命令:

git reflog expire --expire=now --all
git gc --prune=now --aggressive

And forced the history rewriting by git push --force .并通过git push --force强制重写历史记录。

Result: the dirty LFS reference has finally gone!结果:肮脏的 LFS 引用终于消失了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM