git - 在新的 gitlab 存储库中,我收到此错误:LFS 对象丢失。确保正确设置 LFS 或尝试手动“git lfs push --all”
问题描述
我刚刚在该组中建立了一个新的 gitlab 组和一个新的私有 gitlab 存储库。我正在尝试从现有文件夹创建一个项目。
问题
我从现有文件夹中删除了包含所有 git 历史记录的 .git 文件夹。然后我创建了gitlab存储库,执行
git init
git remote add origin git@gitlab.com:my_group_username/my-repo.git
git add .
git commit -m "initial commit"
git push origin master
我收到了这个错误:
! [remote rejected] master -> master (pre-receive hook declined)
我试过的
- 我检查以确保主分支不受保护。它不是。
- 我检查了配置了哪些 webhook。没有了。
- 我尝试推送到一个新分支,而不是名为 master
- 我检查了我的用户配置
git config list
并且我的用户信息已按预期配置。
- 我删除了 repo,重新创建了它,然后尝试推送。同样的问题。
- 我检查以确保我的 gitlab 用户被配置为贡献者。我是项目的所有者。
- 我什至以同样的方式创建了一个 Github 存储库,并且能够毫无问题地将我的提交推送到该存储库。
任何想法可能导致此错误?
编辑 - git push 命令和输出:
git push -u origin --all
Enumerating objects: 31, done.
Counting objects: 100% (31/31), done.
Delta compression using up to 12 threads
Compressing objects: 100% (24/24), done.
Writing objects: 100% (31/31), 78.73 KiB | 8.75 MiB/s, done.
Total 31 (delta 0), 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 gitlab.com:dellacortelab/prospr.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitlab.com:dellacortelab/prospr.git'
再看一遍,LFS(大文件存储)似乎有问题,但存储库的大小只有 1.5 Mb。它原本确实有一些大文件,但我在删除 .git 文件夹之前删除了它们,所以我不知道 gitlab 是如何知道它们的。
更新:
我的 .gitattributes 文件中有对 LFS 文件的引用,所以我删除了 .gitattributes 文件及其引用的目录,但我仍然遇到同样的错误。
删除 .gitattributes 文件:
potts/plmDCA_asymmetric/plmDCA_asymmetric.ctf filter=lfs diff=lfs merge=lfs -text
解决方案
最终解决方案:从 git 历史记录中清除所有对 LFS 文件的引用
- 我删除了该
.gitattributes
文件以及它引用的文件:potts/plmDCA_asymmetric/plmDCA_asymmetric.ctf
,然后再次提交。 - 还是推不开
- 所以我删除了
.git
目录,重新初始化了 git 存储库,然后推送。 - 有效!
可能有更细微的方法来清除引用 LFS 的 git 历史记录,但这很有效。
推荐阅读
- python - 找到图像的中心来定义一个 hitbox
- python - 关于 np.nonzero(arr)[0] 中尾随 [0] 的作用的问题
- linux-kernel - filename_lookup.part.64 vs filename_lookup 符号
- python - 将 NumPy 数据流式传输到 Tensorflow
- javascript - 自定义钩子错误:只能在函数组件的主体内部调用钩子
- r - 将两个量化列绘制到一个 geom_col 图中
- nuxt.js - 如何从 nuxt 插件发出事件?
- node.js - Apollo Server v2 - 未调用 GraphQL 解析器
- c++ - 如果容量用完,编写私有函数来扩展数组
- machine-learning - 错误:“DimensionMismatch(”矩阵 A 的维度为(1024,10),向量 B 的长度为 9“)”在 Julia 中使用 Flux