You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

误配置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文件处于缓存未处理状态导致。

操作背景

  1. 通过brew安装git-lfs
  2. 向项目添加若干*.pdf文件,本地Git推送成功
  3. 执行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配置,仍未解决

最终成功的解决步骤

  1. 删除项目目录下的node_modules文件夹
  2. 执行npm install(原描述中rpm install应为笔误)更新package-lock.json
  3. 执行yarn install更新yarn.lock
  4. 再次执行git push heroku main:main --no-verify,构建成功!

内容的提问来源于stack exchange,提问作者user3763682

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 07:18:25