Ale*_*lex 5 git gitlab git-lfs
我已经将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'
Run Code Online (Sandbox Code Playgroud)
gitURL我的git-repository URL 在哪里
由于错误建议我尝试手动推送我的二进制文件,使用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
Run Code Online (Sandbox Code Playgroud)
这意味着我的理解是我的所有本地文件都已成功存储在我的服务器上.
尝试获取所有lfs文件也可以正常工作:
$ git lfs fetch --all
Scanning for all objects ever referenced...
* 1446 objects found
Fetching objects...
Run Code Online (Sandbox Code Playgroud)
完成没有任何错误.
此外,检查所有lfs文件的一致性git lfs fsck似乎也可以正常工作:
$ git lfs fsck
Git LFS fsck OK
Run Code Online (Sandbox Code Playgroud)
我现在开始没有关于修复此错误的想法了.任何帮助将不胜感激.
mca*_*eaa 11
尽管(据我所知)我的 gitlab 存储库中没有任何 LFS 对象,但我还是收到了此错误。
remote: GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".
Run Code Online (Sandbox Code Playgroud)
解决方案是在 gitlab 项目设置中禁用Git Large File Storage (LFS) 。
设置 > 常规 > 可见性、项目功能、权限 > 展开 > Git 大文件存储 (LFS)
当他们最近引入自己的LFS支持时,这发生在我们的GitLab存储库中.如果你想继续使用你自己的LFS,那么这个过程相当痛苦 - 你需要在每个存储库上禁用它们自己的LFS支持,但似乎没有它的web选项,你需要通过它们来做命令行API:
pip install python-gitlab将配置文件写出~/.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>
Run Code Online (Sandbox Code Playgroud)从设置网页的顶部抓取您的gitlab项目ID
gitlab project update --lfs-enabled false --id <Your project id>我们的一些开发人员报告说,即使这样也不起作用,他们不得不求助于发送手动HTTP PUT请求,https://gitlab.com/api/v4/projects/<Your project id>?lfs_enabled=false并将私有令牌头设置为您的私人令牌.例如,使用CURL:
curl -X PUT --header "Private-Token: <private token>" -F "lfs_enabled=false" https://gitlab.com/api/v4/projects/<project id>
Run Code Online (Sandbox Code Playgroud)
小智 8
这个命令帮助了我:
git lfs ls-files -l | awk '{ print $1 }' | xargs git lfs push --object-id origin
Run Code Online (Sandbox Code Playgroud)
而且它比其他答案更快。