由于丢失或损坏的本地对象 git-lfs,git push 被拒绝

k4j*_*4jc 4 git github bitbucket gitlab git-lfs

我是新手git-lfs,以下是我配置并尝试推送的步骤git-lfs

git clone git@gitlab.example.com:group/project.git 将 tar.gz lfs 文件从不同的 repo 复制到我当前的 repo,然后

git lfs install                      
git lfs track "*.tar.gz"
git add .gitattributes
git commit -m "message"

Run Code Online (Sandbox Code Playgroud)

同时git push origin master

我面临的错误:

(missing) code.tar.gz (f2b4bf22bcb011fef16f80532247665d15edbb9051***)
Uploading LFS objects:   0% (0/1), 0 B | 0 B/s, done.
hint: Your push was rejected due to missing or corrupt local objects.
hint: You can disable this check with: 'git config lfs.allowincompletepush true'
error: failed to push some refs to 'git@gitlab.example.com:group/project.git'
Run Code Online (Sandbox Code Playgroud)

供您参考:当我运行时,我ls .git/lfs/objects/f2/b4无法在里面找到任何东西。

但是对于其他 tar 文件,如果我运行,ls .git/lfs/objects/g3/8a我可以看到 c5a9a2e024875718b6377bb15a42fac872a3**** 值

A-_*_*_-S 7

我通过下载从该特定分支引用的 lfs 对象来解决它:

git lfs fetch --all <remote-name> <branch-name>
Run Code Online (Sandbox Code Playgroud)

它将填充丢失的文件 .git/lfs/objects 文件夹