修改Heroku应用名称后部署报错“No such app as obscure-plains-01212”,如何添加新仓库地址解决该问题
解决Heroku应用重命名后部署报错的问题
别担心,这个问题在Heroku重命名应用后特别常见——本质是本地Git仓库的远程配置还盯着旧的应用名称,导致部署时找不到对应的应用。下面一步步帮你搞定:
第一步:先确认当前的远程仓库配置
在终端里运行这条命令,看看本地Git里的Heroku远程地址是什么:
git remote -v
你大概率会看到类似这样的输出,里面全是旧应用的地址:
heroku https://git.heroku.com/obscure-plains-01212.git (fetch) heroku https://git.heroku.com/obscure-plains-01212.git (push)
第二步:更新或添加新的Heroku远程地址
这里有两种处理方式,推荐第一种直接更新现有远程:
方式1:替换现有Heroku远程地址(推荐)
直接把原来的heroku远程地址换成新的应用仓库地址,运行这条命令就行:
git remote set-url heroku https://git.heroku.com/buzzing-api.git
方式2:添加新的远程仓库(可选)
如果你想保留旧的远程配置(一般没必要),可以新增一个远程,比如命名为heroku-buzzing:
git remote add heroku-buzzing https://git.heroku.com/buzzing-api.git
之后部署时要指定这个新远程:git push heroku-buzzing main(注意把main换成你实际用的分支名)
第三步:验证配置是否生效
再跑一遍git remote -v,确认输出里已经显示新的仓库地址:
heroku https://git.heroku.com/buzzing-api.git (fetch) heroku https://git.heroku.com/buzzing-api.git (push)
第四步:测试部署
现在尝试重新部署应用:
git push heroku main
这次应该就不会再弹出No such app as obscure-plains-01212的错误了。
额外提示:关于Heroku栈的更新
你提到的栈提示“Stack heroku-22 will replace Heroku-20 on the next deploy”是正常的,Heroku会在下次部署时自动帮你切换到heroku-22栈。要是你想主动提前切换,也可以运行:
heroku stack:set heroku-22
内容的提问来源于stack exchange,提问作者Md Firoz Mia
相关产品推荐
相关产品推荐

