误配置Git-LFS导致Heroku推送失败的排查与解决
解决Heroku推送时Git LFS相关错误
问题现象
执行git push heroku main(即使添加--force参数)时,出现以下错误:
batch response: Repository or object not found: https://git.heroku.com/app.git/info/lfs/objects/batch Check that it exists and that you have proper access to it Uploading LFS objects: 0% (0/2), 0 B | 0 B/s, done. error: failed to push some refs to 'https://git.heroku.com/app.git'
直接访问https://git.heroku.com/app.git/info/lfs/objects/batch无法打开,推测是PDF文件处于缓存未处理状态导致。
操作背景
- 通过brew安装git-lfs
- 向项目添加若干
*.pdf文件,本地Git推送成功 - 执行
git push heroku main触发上述错误,随后得知Heroku不支持Git LFS
尝试过的无效修复步骤
- 卸载git-lfs
- 执行
heroku rollback - 通过Heroku后台Settings→Add Buildpack安装
infinitly/heroku-buildpack-git-lfs(命令行操作报错,改用后台安装),但问题未解决,随后移除该Buildpack - 使用
filter-branch移除PDF文件,推送后服务器崩溃,日志显示:Filter chain halted as #<Proc:0x00007f785b6b4380 /app/vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.2/lib/action_controller/metal/allow_browser.rb:58 (lambda)> rendered or redirected,推送仍失败 - 将HEAD变基至添加PDF前的最后一次成功远程推送,执行
git merge --ff-only origin/main更新本地分支后,执行git push heroku main:main及git push heroku main:main --force,仍出现初始错误 - 安装
heroku-builds插件:heroku plugins:install @heroku-cli/heroku-builds,执行heroku builds:cache:purge -a example-app,问题未解决 - 将HEAD变基至误加PDF前的提交,执行
git push heroku main:main --no-verify,并移除.git/config中的LFS配置,仍未解决
最终成功的解决步骤
- 删除项目目录下的
node_modules文件夹 - 执行
npm install(原描述中rpm install应为笔误)更新package-lock.json - 执行
yarn install更新yarn.lock - 再次执行
git push heroku main:main --no-verify,构建成功!
内容的提问来源于stack exchange,提问作者user3763682
相关产品推荐
相关产品推荐

