简体   繁体   English

GitLab 推送错误:LFS 对象丢失

[英]GitLab push error: LFS objects are missing

I've used Git LFS for GitLab for a few months now without any problems, but it returned the following error while pushing files lately:我已经将 Git LFS 用于 GitLab 几个月了,没有任何问题,但最近在推送文件时返回以下错误:

$ git push origin master
Git LFS: (14 of 14 files) 8.88 MB / 8.88 MB
Counting objects: 54, done.
Delta compression using up to 6 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (54/54), 5.42 KiB | 0 bytes/s, done.
Total 54 (delta 15), reused 0 (delta 0)
remote: GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".
To https://gitlab.com/<gitURL>.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://gitlab.com/<gitURL>.git'

where gitURL is my git-repository URL.其中gitURL是我的 git-repository URL。

As the error suggests I tried to manually push my binary files, using git lfs push --all , which gives me the following output:由于错误表明我尝试使用git lfs push --all手动推送我的二进制文件,这给了我以下输出:

$ git lfs push --all origin master
Git LFS: (0 of 0 files, 1370 skipped) 0 B / 0 B, 1.77 GB skipped

which means by my understanding that all my local files are already successfully stored on my server.这意味着根据我的理解,我所有的本地文件都已成功存储在我的服务器上。

Trying to fetch all lfs files does work fine as well:尝试获取所有 lfs 文件也可以正常工作:

$ git lfs fetch --all
Scanning for all objects ever referenced...
* 1446 objects found
Fetching objects...

which finishes without any errors.完成没有任何错误。

Moreover checking all lfs files for consistency using git lfs fsck seems to work fine too:此外,使用git lfs fsck检查所有 lfs 文件的一致性似乎也可以正常工作:

$ git lfs fsck
Git LFS fsck OK

I'm starting to run out of ideas about fixing this error now.我现在开始没有关于修复这个错误的想法了。 Any help would be greatly appreciated.任何帮助将不胜感激。

This happened to our repositories on GitLab when they introduced their own LFS support recently.我们在 GitLab 上的存储库最近推出了自己的 LFS 支持时发生了这种情况。 If you want to continue to use your own LFS then the process is rather painful - you need to disable their own LFS support on each repository, but there doesn't seem to be a web option for it, you need to do it via their command line API:如果你想继续使用你自己的 LFS,那么这个过程是相当痛苦的——你需要在每个存储库上禁用他们自己的 LFS 支持,但似乎没有一个 web 选项,你需要通过他们的命令行 API:

  1. Install the python gitlab command line API: pip install python-gitlab安装python gitlab命令行API: pip install python-gitlab
  2. Setup a private gitlab token for your account, generate it on the Access Tokens portion of your account profile.为您的帐户设置一个私有 gitlab 令牌,在您帐户配置文件的访问令牌部分生成它。
  3. Write a configuration file out to ~/.python-gitlab.cfg :将配置文件写入~/.python-gitlab.cfg

     [global] default = yourrepo ssl_verify = true timeout = 20 [yourrepo] url = https://gitlab.com/ private_token = <your API key from the settings tab on gitlab.com>
  4. Grab your gitlab project id from the top of the settings web page从设置网页的顶部获取您的 gitlab 项目 ID

  5. gitlab project update --lfs-enabled false --id <Your project id>

Some of our developers reported that even this didn't work and they had to resort to sending a manual HTTP PUT request to https://gitlab.com/api/v4/projects/<Your project id>?lfs_enabled=false with a Private-Token header set to your private token.我们的一些开发人员报告说,即使这也不起作用,他们不得不求助于手动发送 HTTP PUT 请求到https://gitlab.com/api/v4/projects/<Your project id>?lfs_enabled=false Private-Token 标头设置为您的私有令牌。 For example, with CURL:例如,使用 CURL:

 curl -X PUT --header "Private-Token: <private token>" -F "lfs_enabled=false" https://gitlab.com/api/v4/projects/<project id>

This command helped me:这个命令帮助了我:

git lfs ls-files -l | awk '{ print $1 }' | xargs git lfs push --object-id origin

And it is faster than the other answer.它比另一个答案更快。

I got this error even though (to my knowledge) I did not have any LFS objects in my gitlab repository.尽管(据我所知)我的 gitlab 存储库中没有任何 LFS 对象,但我还是收到了这个错误。

remote: GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".

The solution was to disable Git Large File Storage (LFS) in the gitlab project settings.解决方案是在 gitlab 项目设置中禁用Git Large File Storage (LFS)

Settings > General > Visibility, project features, permissions > Expand > Git Large File Storage (LFS)设置 > 常规 > 可见性、项目功能、权限 > 展开 > Git 大文件存储 (LFS)

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

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