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

同一Git仓库多Heroku应用,如何调整本地配置仅保留指定应用

解决Git Push到Heroku时的"No such app"错误

别担心,这个问题很常见——你本地Git仓库的heroku远程地址还绑定着已经被你删除的agile-garden-20427应用,所以推送时会找不到对应的仓库。跟着下面的步骤就能快速修复:

步骤1:确认当前的远程仓库配置

先运行这个命令查看所有远程仓库的地址,确认heroku远程指向的是旧应用:

git remote -v

你会看到类似这样的输出(其中heroku对应的是旧应用地址):

heroku  https://git.heroku.com/agile-garden-20427.git (fetch)
heroku  https://git.heroku.com/agile-garden-20427.git (push)

步骤2:删除旧的Heroku远程配置

运行这个命令移除指向已删除应用的heroku远程:

git remote rm heroku

如果提示远程不存在,说明之前的配置可能已经有问题,直接跳过这一步就行。

步骤3:添加指向保留应用的新远程

你有两种简单的方法来添加正确的远程:

方法一:用Heroku CLI自动关联(推荐)

直接通过应用名称让CLI帮你设置正确的远程地址:

heroku git:remote -a workoutcalendar

这个命令会自动把heroku远程绑定到你的workoutcalendar应用。

方法二:手动添加远程地址

如果你知道应用的Git仓库地址,也可以手动添加:

git remote add heroku https://git.heroku.com/workoutcalendar.git

步骤4:验证新的远程配置

再运行一次git remote -v,确认heroku远程现在指向的是workoutcalendar:

heroku  https://git.heroku.com/workoutcalendar.git (fetch)
heroku  https://git.heroku.com/workoutcalendar.git (push)

步骤5:正常推送代码

现在你可以正常推送代码到Heroku了:

git push heroku master

注意:如果你的本地主分支是main(现在很多仓库默认用这个分支名),把命令改成git push heroku main即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 03:29:06