git - 这个 git-LFS 损坏的文件错误是什么意思以及如何修复它?

标签 git github git-lfs

我不确定为什么,但我的 repo 协议(protocol)有点搞砸了,当我尝试将我的分支推送到 github 时,我收到一个错误:

> git push
Git LFS: (0 of 1 files) 0 B / 61.99 MB
LFS upload failed:
  (missing) path/to/bigfile (50...4b)
error: failed to push some refs to 'git@github.com:me/myproject'

> git-lfs ls-files
50.. - path/to/bigfile

>  git-lfs fsck
Object path/to/bigfile (50...4b) could not be checked: no such file or directory
Object path/to/bigfile (50...4b) could not be checked: no such file or directory
Moving corrupt objects to /Users/myname/.../.git/lfs/bad
rename /Users/myname/.../.git/lfs/objects/50/b6/50...4b 
/Users/myname/.../.git/lfs/bad/50...4b: no such file or directory  

请注意,我不关心删除或删除这个文件,它不再被使用。 (但文件在那里!) 我试过 git-lfs untrack path/to/bigfile 但没有成功,我无法推送我的分支。

如何解决这个问题?

最佳答案

修复损坏的 lfs 而不重写历史的方法:

# set origin to original repo
git remote set-url origin ssh://git@bitbucket.nl.xxx:7999/prod/A.git
git lfs update

# fetch lfs data from original repo
git lfs fetch --all origin

# set origin back to new repo
git remote set-url origin ssh://git@bitbucket.nl.xxx:7999/prod/B.git
git lfs update 

# get missing lfs data from new repo
git lfs fetch --all origin

# push missing lfs data in new repo
git lfs push –all origin

# final check
git clone ssh://git@bitbucket.nl.xxx:7999/prod/B.git
git lfs fetch --all origin
git lfs fsck 

关于git - 这个 git-LFS 损坏的文件错误是什么意思以及如何修复它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46595617/

相关文章:

git - merge 后如何在git-lfs中修复Unity .prefab文件

git - 如何获得直接链接到github LFS(大文件存储)中的文件?

android - Glide Process 'command ' git'' 以非零退出值 128 完成

git - `git diff HEAD^` 的反义词是什么?

git - 如何在git中将文件 "Un-push"?

git - merge 后我丢失了未提交的更改

Git 错误 : "Please make sure you have the correct access rights and the repository exists"

git 提交前和提交后 Hook 未运行

git - 限制分支 X 仅从 Github 中的一个特定分支 Y merge

git - git lfs migrate import 后文件变得无法读取,如何撤消